From patchwork Mon Apr 13 13:22:03 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 47119 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wg0-f71.google.com (mail-wg0-f71.google.com [74.125.82.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id D2C7920553 for ; Mon, 13 Apr 2015 13:22:10 +0000 (UTC) Received: by wgiv13 with SMTP id v13sf17550949wgi.3 for ; Mon, 13 Apr 2015 06:22:09 -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:cc:subject :date:message-id:in-reply-to:references:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe; bh=s9L3hpUgHBw9SAlUdfJFM1ZwMLe5TYpB8+299aNm89o=; b=knAfl8wjb16ZpI+NeQo3CNSwm02AuF95hBtacMHxyZGbEXwU0DNlwcbD0CIEwwjEtw O6IOn25IDUlCcKBV0O5CyS0Y3Io6rz68P2Yz9lTBZiNGQPm53qwVSuMIJVlbzV33Vaa6 deiKN1xBxBN54GvvcO/qxYZHqfwg+mdkMTI2TRliryvtZnAg4L2WZ1Wz4eZp3Q8urt+a YzIKp3XDxWltsaRgvUcN+92NwJDYn3uO06/YKyVVTXJwZdJ27ik3kHxy7+11OYYng0kx 7KYtoW0Csb59PEtKuD+V4BAnA/3ApEuIkSnwZQGJlE8w4G0/NRU8f1lInVv1eKNskd0F aviQ== X-Gm-Message-State: ALoCoQmfYMSq33Z4cKTeP9j3u4lW9rUXn6/ShclfsaCtjW+n8J2wph8R8l1+AJN64PgRvh1LaZ2B X-Received: by 10.112.17.105 with SMTP id n9mr2154216lbd.8.1428931329582; Mon, 13 Apr 2015 06:22:09 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.88.110 with SMTP id bf14ls654815lab.48.gmail; Mon, 13 Apr 2015 06:22:09 -0700 (PDT) X-Received: by 10.113.4.105 with SMTP id cd9mr13333796lbd.38.1428931329446; Mon, 13 Apr 2015 06:22:09 -0700 (PDT) Received: from mail-lb0-f180.google.com (mail-lb0-f180.google.com. [209.85.217.180]) by mx.google.com with ESMTPS id xg7si8412955lbb.48.2015.04.13.06.22.09 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 13 Apr 2015 06:22:09 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.180 as permitted sender) client-ip=209.85.217.180; Received: by lbbqq2 with SMTP id qq2so58344403lbb.3 for ; Mon, 13 Apr 2015 06:22:09 -0700 (PDT) X-Received: by 10.152.23.70 with SMTP id k6mr13024693laf.76.1428931329323; Mon, 13 Apr 2015 06:22:09 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.112.67.65 with SMTP id l1csp1201415lbt; Mon, 13 Apr 2015 06:22:08 -0700 (PDT) X-Received: by 10.180.104.131 with SMTP id ge3mr7233575wib.12.1428931328503; Mon, 13 Apr 2015 06:22:08 -0700 (PDT) Received: from mnementh.archaic.org.uk (mnementh.archaic.org.uk. [2001:8b0:1d0::1]) by mx.google.com with ESMTPS id ca6si17608349wjc.38.2015.04.13.06.22.07 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Mon, 13 Apr 2015 06:22:08 -0700 (PDT) Received-SPF: none (google.com: pm215@archaic.org.uk does not designate permitted sender hosts) client-ip=2001:8b0:1d0::1; Received: from pm215 by mnementh.archaic.org.uk with local (Exim 4.80) (envelope-from ) id 1YheJR-0001JW-1C; Mon, 13 Apr 2015 14:22:05 +0100 From: Peter Maydell To: qemu-devel@nongnu.org Cc: patches@linaro.org, Greg Bellows , Paolo Bonzini , Richard Henderson , "Edgar E. Iglesias" , Peter Crosthwaite , =?UTF-8?q?Alex=20Benn=C3=A9e?= Subject: [PATCH v2 13/14] target-arm: Use attribute info to handle user-only watchpoints Date: Mon, 13 Apr 2015 14:22:03 +0100 Message-Id: <1428931324-4973-14-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1428931324-4973-1-git-send-email-peter.maydell@linaro.org> References: <1428931324-4973-1-git-send-email-peter.maydell@linaro.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.180 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Now that we have memory access attribute information in the watchpoint checking code, we can correctly implement handling of watchpoints which should match only on userspace accesses, where LDRT/STRT/LDT/STT from EL1 are treated as userspace accesses. Signed-off-by: Peter Maydell Reviewed-by: Edgar E. Iglesias Reviewed-by: Alex Bennée --- target-arm/op_helper.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/target-arm/op_helper.c b/target-arm/op_helper.c index 7713022..4a8c4e0 100644 --- a/target-arm/op_helper.c +++ b/target-arm/op_helper.c @@ -602,13 +602,22 @@ static bool bp_wp_matches(ARMCPU *cpu, int n, bool is_wp) int pac, hmc, ssc, wt, lbn; /* TODO: check against CPU security state when we implement TrustZone */ bool is_secure = false; + int access_el = arm_current_el(env); if (is_wp) { - if (!env->cpu_watchpoint[n] - || !(env->cpu_watchpoint[n]->flags & BP_WATCHPOINT_HIT)) { + CPUWatchpoint *wp = env->cpu_watchpoint[n]; + + if (!wp || !(wp->flags & BP_WATCHPOINT_HIT)) { return false; } cr = env->cp15.dbgwcr[n]; + if (wp->hitattrs.user) { + /* The LDRT/STRT/LDT/STT "unprivileged access" instructions should + * match watchpoints as if they were accesses done at EL0, even if + * the CPU is at EL1 or higher. + */ + access_el = 0; + } } else { uint64_t pc = is_a64(env) ? env->pc : env->regs[15]; @@ -649,15 +658,7 @@ static bool bp_wp_matches(ARMCPU *cpu, int n, bool is_wp) break; } - /* TODO: this is not strictly correct because the LDRT/STRT/LDT/STT - * "unprivileged access" instructions should match watchpoints as if - * they were accesses done at EL0, even if the CPU is at EL1 or higher. - * Implementing this would require reworking the core watchpoint code - * to plumb the mmu_idx through to this point. Luckily Linux does not - * rely on this behaviour currently. - * For breakpoints we do want to use the current CPU state. - */ - switch (arm_current_el(env)) { + switch (access_el) { case 3: case 2: if (!hmc) {