From patchwork Fri Sep 12 13:23:40 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 37304 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-we0-f197.google.com (mail-we0-f197.google.com [74.125.82.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 876AB20F2E for ; Fri, 12 Sep 2014 13:27:31 +0000 (UTC) Received: by mail-we0-f197.google.com with SMTP id w61sf489641wes.4 for ; Fri, 12 Sep 2014 06:27:30 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:date :message-id:in-reply-to:references:subject:precedence:list-id :list-unsubscribe:list-archive:list-post:list-help:list-subscribe :errors-to:sender:x-original-sender :x-original-authentication-results:mailing-list; bh=SaqjMiXWwCjgRFofsvDxxRxJtaaMpoIBfcGxpX5YsnE=; b=OKps5KatcG/CrUwAnYyzHhtNFl5SkF0+PsvbijIpAaEF9a4abWtvY6BFqsY3wKdB6X 91ScbI3r4R6exRz3w7rBTCSpWeok1DddR1un8Jy+H8Q1rzY01MxIbNHiVOvWGQpfgUPm T1ir+1acGOceL1Leb6Rzvf8iS/Hdk0KQ2RBVa/ICB/z2o8qkX/J31/rb9X95uyyX4mWN N/m9G3yTYC/ayHq/Oq0zEroV3uvvcXRoh/Obb10z/i6YiApM6jvXGE+/Etk/4awjNVmr OOyJjkA+s+3HkfzdgkH59681valBcZuNrop63A5ZfxcPRfKXdNDHD8Bafcdwp/dFvrLc MNQw== X-Gm-Message-State: ALoCoQkO2gYN/+WQaKxQ+297VsAd9/2wJqsor2rM8x5iz1gWjvTHXAx01kYAx6qOGqynlB7ED3iy X-Received: by 10.112.184.197 with SMTP id ew5mr2290846lbc.0.1410528450471; Fri, 12 Sep 2014 06:27:30 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.5.195 with SMTP id u3ls171851lau.107.gmail; Fri, 12 Sep 2014 06:27:30 -0700 (PDT) X-Received: by 10.152.19.66 with SMTP id c2mr9244953lae.64.1410528450336; Fri, 12 Sep 2014 06:27:30 -0700 (PDT) Received: from mail-lb0-f177.google.com (mail-lb0-f177.google.com [209.85.217.177]) by mx.google.com with ESMTPS id oc4si6613309lbb.11.2014.09.12.06.27.30 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 12 Sep 2014 06:27:30 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.177 as permitted sender) client-ip=209.85.217.177; Received: by mail-lb0-f177.google.com with SMTP id l4so879652lbv.8 for ; Fri, 12 Sep 2014 06:27:30 -0700 (PDT) X-Received: by 10.112.62.200 with SMTP id a8mr8509434lbs.34.1410528450266; Fri, 12 Sep 2014 06:27:30 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.141.42 with SMTP id rl10csp731075lbb; Fri, 12 Sep 2014 06:27:29 -0700 (PDT) X-Received: by 10.224.47.67 with SMTP id m3mr6752184qaf.28.1410528448632; Fri, 12 Sep 2014 06:27:28 -0700 (PDT) Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id g69si5567990qgg.113.2014.09.12.06.27.28 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Fri, 12 Sep 2014 06:27:28 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Received: from localhost ([::1]:44923 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XSQsp-0003NY-DL for patch@linaro.org; Fri, 12 Sep 2014 09:27:27 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56903) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XSQpX-0006pm-Ek for qemu-devel@nongnu.org; Fri, 12 Sep 2014 09:24:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XSQpS-0003zQ-9l for qemu-devel@nongnu.org; Fri, 12 Sep 2014 09:24:03 -0400 Received: from mnementh.archaic.org.uk ([81.2.115.146]:46961) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XSQpS-0003xi-2E for qemu-devel@nongnu.org; Fri, 12 Sep 2014 09:23:58 -0400 Received: from pm215 by mnementh.archaic.org.uk with local (Exim 4.80) (envelope-from ) id 1XSQpO-0003Xe-U5 for qemu-devel@nongnu.org; Fri, 12 Sep 2014 14:23:54 +0100 From: Peter Maydell To: qemu-devel@nongnu.org Date: Fri, 12 Sep 2014 14:23:40 +0100 Message-Id: <1410528234-13545-10-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1410528234-13545-1-git-send-email-peter.maydell@linaro.org> References: <1410528234-13545-1-git-send-email-peter.maydell@linaro.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 81.2.115.146 Subject: [Qemu-devel] [PULL 09/23] exec.c: Record watchpoint fault address and direction X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: peter.maydell@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.177 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 When we check whether we've hit a watchpoint we know the address that we were attempting to access and whether it was a read or a write. Record this information in the CPUWatchpoint struct so that target-specific code can report it to the guest. Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson --- exec.c | 7 ++++++- include/qom/cpu.h | 6 +++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/exec.c b/exec.c index 181ade0..2794b4b 100644 --- a/exec.c +++ b/exec.c @@ -1673,7 +1673,12 @@ static void check_watchpoint(int offset, int len, int flags) QTAILQ_FOREACH(wp, &cpu->watchpoints, entry) { if (cpu_watchpoint_address_matches(wp, vaddr, len) && (wp->flags & flags)) { - wp->flags |= BP_WATCHPOINT_HIT; + if (flags == BP_MEM_READ) { + wp->flags |= BP_WATCHPOINT_HIT_READ; + } else { + wp->flags |= BP_WATCHPOINT_HIT_WRITE; + } + wp->hitaddr = vaddr; if (!cpu->watchpoint_hit) { cpu->watchpoint_hit = wp; tb_check_watchpoint(cpu); diff --git a/include/qom/cpu.h b/include/qom/cpu.h index 7c06f37..c325774 100644 --- a/include/qom/cpu.h +++ b/include/qom/cpu.h @@ -170,6 +170,7 @@ typedef struct CPUBreakpoint { typedef struct CPUWatchpoint { vaddr vaddr; vaddr len; + vaddr hitaddr; int flags; /* BP_* */ QTAILQ_ENTRY(CPUWatchpoint) entry; } CPUWatchpoint; @@ -622,9 +623,12 @@ void cpu_single_step(CPUState *cpu, int enabled); #define BP_MEM_WRITE 0x02 #define BP_MEM_ACCESS (BP_MEM_READ | BP_MEM_WRITE) #define BP_STOP_BEFORE_ACCESS 0x04 -#define BP_WATCHPOINT_HIT 0x08 +/* 0x08 currently unused */ #define BP_GDB 0x10 #define BP_CPU 0x20 +#define BP_WATCHPOINT_HIT_READ 0x40 +#define BP_WATCHPOINT_HIT_WRITE 0x80 +#define BP_WATCHPOINT_HIT (BP_WATCHPOINT_HIT_READ | BP_WATCHPOINT_HIT_WRITE) int cpu_breakpoint_insert(CPUState *cpu, vaddr pc, int flags, CPUBreakpoint **breakpoint);