From patchwork Fri Aug 8 12:18:07 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 35112 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-oi0-f71.google.com (mail-oi0-f71.google.com [209.85.218.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 205CF21457 for ; Fri, 8 Aug 2014 12:19:43 +0000 (UTC) Received: by mail-oi0-f71.google.com with SMTP id e131sf19616340oig.10 for ; Fri, 08 Aug 2014 05:19:42 -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:cc: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=v5blSmVTH/HerydOCibB0tdIqNlKJRSl90wCqCXJf8A=; b=XywEepUBY6kwMWERDwWfnQQ8buN5b73+luOXNWdxTNHQiflMCn0J6aQ7zDFdSUxyOE N5fLqkMakpZ9yWCWkjmtyyOMUzanWjZXxQXP/jUiZisAWFdDYsJ8x1IJnyRNsHtXTMp6 u640/tcPO2xy3xo6DkVV2roSLZsQHpex0tFRIy7CGs2cFiT8P8LEA4LBA2M8GatQVKbb dw/1TPhfbY+0nqP4Acy3Y50g14pAeZaTriCILqbZdLfK4YISmqc4RLMmYphifBnDDov8 AAMv1R0sRoNAoT84HdSKSTnQ6+yO1rAPVB8F9SQx7L8j5jOLy7lWZ5LgEjfcC4H4suEC rqNw== X-Gm-Message-State: ALoCoQnr3bBpqI6IitkjGAzNyAFwrvHS2yMT0wKKNaDRV13gm30w8xZpJdshyYo/x3kcEpyKT3vd X-Received: by 10.182.241.1 with SMTP id we1mr11732384obc.37.1407500382765; Fri, 08 Aug 2014 05:19:42 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.93.137 with SMTP id d9ls505841qge.30.gmail; Fri, 08 Aug 2014 05:19:42 -0700 (PDT) X-Received: by 10.220.7.131 with SMTP id d3mr475615vcd.49.1407500382671; Fri, 08 Aug 2014 05:19:42 -0700 (PDT) Received: from mail-vc0-f178.google.com (mail-vc0-f178.google.com [209.85.220.178]) by mx.google.com with ESMTPS id p6si2827647veh.15.2014.08.08.05.19.42 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 08 Aug 2014 05:19:42 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.178 as permitted sender) client-ip=209.85.220.178; Received: by mail-vc0-f178.google.com with SMTP id la4so8210775vcb.37 for ; Fri, 08 Aug 2014 05:19:42 -0700 (PDT) X-Received: by 10.220.189.3 with SMTP id dc3mr52100vcb.64.1407500382524; Fri, 08 Aug 2014 05:19:42 -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.221.37.5 with SMTP id tc5csp118107vcb; Fri, 8 Aug 2014 05:19:42 -0700 (PDT) X-Received: by 10.224.55.131 with SMTP id u3mr36534509qag.98.1407500381650; Fri, 08 Aug 2014 05:19:41 -0700 (PDT) Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id u9si10017370qag.56.2014.08.08.05.19.41 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Fri, 08 Aug 2014 05:19:41 -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]:50809 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XFj93-0002Wx-6D for patch@linaro.org; Fri, 08 Aug 2014 08:19:41 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58722) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XFj7q-0001IJ-OD for qemu-devel@nongnu.org; Fri, 08 Aug 2014 08:18:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XFj7n-0007Gs-OW for qemu-devel@nongnu.org; Fri, 08 Aug 2014 08:18:26 -0400 Received: from mnementh.archaic.org.uk ([2001:8b0:1d0::1]:48924) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XFj7n-0007Fb-EC for qemu-devel@nongnu.org; Fri, 08 Aug 2014 08:18:23 -0400 Received: from pm215 by mnementh.archaic.org.uk with local (Exim 4.80) (envelope-from ) id 1XFj7e-0002oy-Mg; Fri, 08 Aug 2014 13:18:14 +0100 From: Peter Maydell To: qemu-devel@nongnu.org Date: Fri, 8 Aug 2014 13:18:07 +0100 Message-Id: <1407500294-10804-5-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1407500294-10804-1-git-send-email-peter.maydell@linaro.org> References: <1407500294-10804-1-git-send-email-peter.maydell@linaro.org> X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2001:8b0:1d0::1 Cc: David Long Subject: [Qemu-devel] [PATCH 04/11] target-arm: Adjust debug ID registers per-CPU 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.220.178 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 Allow each CPU type to specify the value for the debug ID registers, by putting them in the ARMCPU struct, and use the resulting information to only expose the correct number of watchpoint and breakpoint registers for the CPU. Signed-off-by: Peter Maydell --- target-arm/cpu-qom.h | 1 + target-arm/cpu.c | 3 +++ target-arm/cpu64.c | 1 + target-arm/helper.c | 33 ++++++++++++++++++++++++++------- 4 files changed, 31 insertions(+), 7 deletions(-) diff --git a/target-arm/cpu-qom.h b/target-arm/cpu-qom.h index ee4fbb1..07f3c9e 100644 --- a/target-arm/cpu-qom.h +++ b/target-arm/cpu-qom.h @@ -148,6 +148,7 @@ typedef struct ARMCPU { uint64_t id_aa64isar1; uint64_t id_aa64mmfr0; uint64_t id_aa64mmfr1; + uint32_t dbgdidr; uint32_t clidr; /* The elements of this array are the CCSIDR values for each cache, * in the order L1DCache, L1ICache, L2DCache, L2ICache, etc. diff --git a/target-arm/cpu.c b/target-arm/cpu.c index 7cebb76..e27cca2 100644 --- a/target-arm/cpu.c +++ b/target-arm/cpu.c @@ -640,6 +640,7 @@ static void cortex_a8_initfn(Object *obj) cpu->id_isar2 = 0x21232031; cpu->id_isar3 = 0x11112131; cpu->id_isar4 = 0x00111142; + cpu->dbgdidr = 0x15141000; cpu->clidr = (1 << 27) | (2 << 24) | 3; cpu->ccsidr[0] = 0xe007e01a; /* 16k L1 dcache. */ cpu->ccsidr[1] = 0x2007e01a; /* 16k L1 icache. */ @@ -712,6 +713,7 @@ static void cortex_a9_initfn(Object *obj) cpu->id_isar2 = 0x21232041; cpu->id_isar3 = 0x11112131; cpu->id_isar4 = 0x00111142; + cpu->dbgdidr = 0x35141000; cpu->clidr = (1 << 27) | (1 << 24) | 3; cpu->ccsidr[0] = 0xe00fe015; /* 16k L1 dcache. */ cpu->ccsidr[1] = 0x200fe015; /* 16k L1 icache. */ @@ -773,6 +775,7 @@ static void cortex_a15_initfn(Object *obj) cpu->id_isar2 = 0x21232041; cpu->id_isar3 = 0x11112131; cpu->id_isar4 = 0x10011142; + cpu->dbgdidr = 0x3515f021; cpu->clidr = 0x0a200023; cpu->ccsidr[0] = 0x701fe00a; /* 32K L1 dcache */ cpu->ccsidr[1] = 0x201fe00a; /* 32K L1 icache */ diff --git a/target-arm/cpu64.c b/target-arm/cpu64.c index 8b2081c..38d2b84 100644 --- a/target-arm/cpu64.c +++ b/target-arm/cpu64.c @@ -127,6 +127,7 @@ static void aarch64_a57_initfn(Object *obj) cpu->id_aa64dfr0 = 0x10305106; cpu->id_aa64isar0 = 0x00010000; cpu->id_aa64mmfr0 = 0x00001124; + cpu->dbgdidr = 0x3516d000; cpu->clidr = 0x0a200023; cpu->ccsidr[0] = 0x701fe00a; /* 32KB L1 dcache */ cpu->ccsidr[1] = 0x201fe012; /* 48KB L1 icache */ diff --git a/target-arm/helper.c b/target-arm/helper.c index 700057d..22bf6d3 100644 --- a/target-arm/helper.c +++ b/target-arm/helper.c @@ -2186,12 +2186,6 @@ static CPAccessResult ctr_el0_access(CPUARMState *env, const ARMCPRegInfo *ri) } static const ARMCPRegInfo debug_cp_reginfo[] = { - /* DBGDIDR: just RAZ. In particular this means the "debug architecture - * version" bits will read as a reserved value, which should cause - * Linux to not try to use the debug hardware. - */ - { .name = "DBGDIDR", .cp = 14, .crn = 0, .crm = 0, .opc1 = 0, .opc2 = 0, - .access = PL0_R, .type = ARM_CP_CONST, .resetvalue = 0 }, /* DBGDRAR, DBGDSAR: always RAZ since we don't implement memory mapped * debug components. The AArch64 version of DBGDRAR is named MDRAR_EL1; * unlike DBGDRAR it is never accessible from EL0. @@ -2233,14 +2227,32 @@ static void define_debug_regs(ARMCPU *cpu) * These are just dummy implementations for now. */ int i; + int wrps, brps; + ARMCPRegInfo dbgdidr = { + .name = "DBGDIDR", .cp = 14, .crn = 0, .crm = 0, .opc1 = 0, .opc2 = 0, + .access = PL0_R, .type = ARM_CP_CONST, .resetvalue = cpu->dbgdidr, + }; + + brps = extract32(cpu->dbgdidr, 24, 4); + wrps = extract32(cpu->dbgdidr, 28, 4); + + /* The DBGDIDR and ID_AA64DFR0_EL1 define various properties + * of the debug registers such as number of breakpoints; + * check that if they both exist then they agree. + */ + if (arm_feature(&cpu->env, ARM_FEATURE_AARCH64)) { + assert(extract32(cpu->id_aa64dfr0, 12, 4) == brps); + assert(extract32(cpu->id_aa64dfr0, 20, 4) == wrps); + } + define_one_arm_cp_reg(cpu, &dbgdidr); define_arm_cp_regs(cpu, debug_cp_reginfo); if (arm_feature(&cpu->env, ARM_FEATURE_LPAE)) { define_arm_cp_regs(cpu, debug_lpae_cp_reginfo); } - for (i = 0; i < 16; i++) { + for (i = 0; i < brps + 1; i++) { ARMCPRegInfo dbgregs[] = { { .name = "DBGBVR", .state = ARM_CP_STATE_BOTH, .cp = 14, .opc0 = 2, .opc1 = 0, .crn = 0, .crm = i, .opc2 = 4, @@ -2250,6 +2262,13 @@ static void define_debug_regs(ARMCPU *cpu) .cp = 14, .opc0 = 2, .opc1 = 0, .crn = 0, .crm = i, .opc2 = 5, .access = PL1_RW, .fieldoffset = offsetof(CPUARMState, cp15.dbgbcr[i]) }, + REGINFO_SENTINEL + }; + define_arm_cp_regs(cpu, dbgregs); + } + + for (i = 0; i < wrps + 1; i++) { + ARMCPRegInfo dbgregs[] = { { .name = "DBGWVR", .state = ARM_CP_STATE_BOTH, .cp = 14, .opc0 = 2, .opc1 = 0, .crn = 0, .crm = i, .opc2 = 6, .access = PL1_RW,