From patchwork Mon Sep 4 12:25:32 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 111565 Delivered-To: patch@linaro.org Received: by 10.140.94.166 with SMTP id g35csp1470165qge; Mon, 4 Sep 2017 05:35:45 -0700 (PDT) X-Google-Smtp-Source: ADKCNb4oHomeX3AqkLoK03mcit8/ApI7KKaGdqUHEaVUbWPqD1wuVSKALDB30M8usVRjc4wUjsve X-Received: by 10.200.35.193 with SMTP id r1mr385632qtr.95.1504528545675; Mon, 04 Sep 2017 05:35:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1504528545; cv=none; d=google.com; s=arc-20160816; b=XUCwyhNEEYZLTe+PAixdANgMDqHsAz98yt7wGVc4rhC0gUksw8P7zvISjv4wy+I5no Jns1B2GImZx9GOVJxXKxMlWuAMeL+RgYiT0yCfQelKVw684vACsRejn13q9p7o5iHblr e435GhfF01u+iBeUuQM7tOsjbEiQp+DM3XeOi+UQWaJxtOjhT6Q23GL34hsfXNpUhEPr xRcDGXtUOyjmluqZTfO+IOwyb8guVd/JWnm7hlFaPXdmVoqRfSAkMin0DhFEsMDpM8ro xqd/oHK6t6hIZn27GZZTXPNkUsgKhMWtDkERBh0G4glGwVIA7GUA4S3h1zEyzU7XTdJK RDGA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:arc-authentication-results; bh=etSa8Vu8vBxP4knMfKD9HGpRlTiuBIXkqNmlm9ZodUE=; b=dBXI9+VRi+X9gaE+lZofD574LSDYvA6IhNaufkZYVyBqQXcGRJS+xPORMN0pJ1vDfA yezw4P+Z0p4UkcNVJL3d+jRkqmTTh0lo4z+uIC8UB2VkG5cxyeaBkiFsV4B2kCsYM5/D iYIPM60JJW0TQ6ARo4LGcB6BVKLKsWATeeYC2oOWOa1pO4t9pjyj5CfuVCP9O6C8ddEm YV0e1s8ll8+Sn0M3yqfH7SKQ7GYG6j8OWMjmXWBU2RZSl51RgJMKWnGCeEsRGP72fwI+ 6R7KQythnxHSUGFhE73RQtx5ERLnrn+8Wr394jf8yUbawWv9H2KpAsuzAqxiSEAlXmkQ +5xA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id d201si5242354qke.202.2017.09.04.05.35.45 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 04 Sep 2017 05:35:45 -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; Authentication-Results: mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:59580 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1doqbP-0003e3-Be for patch@linaro.org; Mon, 04 Sep 2017 08:35:43 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52323) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1doqSE-0004r9-Hi for qemu-devel@nongnu.org; Mon, 04 Sep 2017 08:26:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1doqS4-0004dD-0R for qemu-devel@nongnu.org; Mon, 04 Sep 2017 08:26:14 -0400 Received: from orth.archaic.org.uk ([2001:8b0:1d0::2]:37104) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1doqS3-0004RY-NO for qemu-devel@nongnu.org; Mon, 04 Sep 2017 08:26:03 -0400 Received: from pm215 by orth.archaic.org.uk with local (Exim 4.89) (envelope-from ) id 1doqRs-0005PK-7l for qemu-devel@nongnu.org; Mon, 04 Sep 2017 13:25:52 +0100 From: Peter Maydell To: qemu-devel@nongnu.org Date: Mon, 4 Sep 2017 13:25:32 +0100 Message-Id: <1504527967-29248-2-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1504527967-29248-1-git-send-email-peter.maydell@linaro.org> References: <1504527967-29248-1-git-send-email-peter.maydell@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2001:8b0:1d0::2 Subject: [Qemu-devel] [PULL 01/36] target/arm: Use MMUAccessType enum rather than int X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 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" In the ARM get_phys_addr() code, switch to using the MMUAccessType enum and its MMU_* values rather than int and literal 0/1/2. Signed-off-by: Peter Maydell Reviewed-by: Edgar E. Iglesias Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson Message-id: 1501692241-23310-2-git-send-email-peter.maydell@linaro.org --- target/arm/internals.h | 3 ++- target/arm/helper.c | 30 +++++++++++++++--------------- 2 files changed, 17 insertions(+), 16 deletions(-) -- 2.7.4 diff --git a/target/arm/internals.h b/target/arm/internals.h index 1f6efef..bb06946 100644 --- a/target/arm/internals.h +++ b/target/arm/internals.h @@ -457,7 +457,8 @@ struct ARMMMUFaultInfo { }; /* Do a page table walk and add page to TLB if possible */ -bool arm_tlb_fill(CPUState *cpu, vaddr address, int rw, int mmu_idx, +bool arm_tlb_fill(CPUState *cpu, vaddr address, + MMUAccessType access_type, int mmu_idx, uint32_t *fsr, ARMMMUFaultInfo *fi); /* Return true if the stage 1 translation regime is using LPAE format page diff --git a/target/arm/helper.c b/target/arm/helper.c index 0ec92d3..8e148be 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -20,13 +20,13 @@ #ifndef CONFIG_USER_ONLY static bool get_phys_addr(CPUARMState *env, target_ulong address, - int access_type, ARMMMUIdx mmu_idx, + MMUAccessType access_type, ARMMMUIdx mmu_idx, hwaddr *phys_ptr, MemTxAttrs *attrs, int *prot, target_ulong *page_size, uint32_t *fsr, ARMMMUFaultInfo *fi); static bool get_phys_addr_lpae(CPUARMState *env, target_ulong address, - int access_type, ARMMMUIdx mmu_idx, + MMUAccessType access_type, ARMMMUIdx mmu_idx, hwaddr *phys_ptr, MemTxAttrs *txattrs, int *prot, target_ulong *page_size_ptr, uint32_t *fsr, ARMMMUFaultInfo *fi); @@ -2135,7 +2135,7 @@ static CPAccessResult ats_access(CPUARMState *env, const ARMCPRegInfo *ri, } static uint64_t do_ats_write(CPUARMState *env, uint64_t value, - int access_type, ARMMMUIdx mmu_idx) + MMUAccessType access_type, ARMMMUIdx mmu_idx) { hwaddr phys_addr; target_ulong page_size; @@ -2194,7 +2194,7 @@ static uint64_t do_ats_write(CPUARMState *env, uint64_t value, static void ats_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value) { - int access_type = ri->opc2 & 1; + MMUAccessType access_type = ri->opc2 & 1 ? MMU_DATA_STORE : MMU_DATA_LOAD; uint64_t par64; ARMMMUIdx mmu_idx; int el = arm_current_el(env); @@ -2253,7 +2253,7 @@ static void ats_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value) static void ats1h_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value) { - int access_type = ri->opc2 & 1; + MMUAccessType access_type = ri->opc2 & 1 ? MMU_DATA_STORE : MMU_DATA_LOAD; uint64_t par64; par64 = do_ats_write(env, value, access_type, ARMMMUIdx_S2NS); @@ -2273,7 +2273,7 @@ static CPAccessResult at_s1e2_access(CPUARMState *env, const ARMCPRegInfo *ri, static void ats_write64(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value) { - int access_type = ri->opc2 & 1; + MMUAccessType access_type = ri->opc2 & 1 ? MMU_DATA_STORE : MMU_DATA_LOAD; ARMMMUIdx mmu_idx; int secure = arm_is_secure_below_el3(env); @@ -7505,7 +7505,7 @@ static uint64_t arm_ldq_ptw(CPUState *cs, hwaddr addr, bool is_secure, } static bool get_phys_addr_v5(CPUARMState *env, uint32_t address, - int access_type, ARMMMUIdx mmu_idx, + MMUAccessType access_type, ARMMMUIdx mmu_idx, hwaddr *phys_ptr, int *prot, target_ulong *page_size, uint32_t *fsr, ARMMMUFaultInfo *fi) @@ -7621,7 +7621,7 @@ do_fault: } static bool get_phys_addr_v6(CPUARMState *env, uint32_t address, - int access_type, ARMMMUIdx mmu_idx, + MMUAccessType access_type, ARMMMUIdx mmu_idx, hwaddr *phys_ptr, MemTxAttrs *attrs, int *prot, target_ulong *page_size, uint32_t *fsr, ARMMMUFaultInfo *fi) @@ -7728,7 +7728,7 @@ static bool get_phys_addr_v6(CPUARMState *env, uint32_t address, if (pxn && !regime_is_user(env, mmu_idx)) { xn = 1; } - if (xn && access_type == 2) + if (xn && access_type == MMU_INST_FETCH) goto do_fault; if (arm_feature(env, ARM_FEATURE_V6K) && @@ -7843,7 +7843,7 @@ static bool check_s2_mmu_setup(ARMCPU *cpu, bool is_aa64, int level, } static bool get_phys_addr_lpae(CPUARMState *env, target_ulong address, - int access_type, ARMMMUIdx mmu_idx, + MMUAccessType access_type, ARMMMUIdx mmu_idx, hwaddr *phys_ptr, MemTxAttrs *txattrs, int *prot, target_ulong *page_size_ptr, uint32_t *fsr, ARMMMUFaultInfo *fi) @@ -8251,7 +8251,7 @@ static inline bool m_is_system_region(CPUARMState *env, uint32_t address) } static bool get_phys_addr_pmsav7(CPUARMState *env, uint32_t address, - int access_type, ARMMMUIdx mmu_idx, + MMUAccessType access_type, ARMMMUIdx mmu_idx, hwaddr *phys_ptr, int *prot, uint32_t *fsr) { ARMCPU *cpu = arm_env_get_cpu(env); @@ -8410,7 +8410,7 @@ static bool get_phys_addr_pmsav7(CPUARMState *env, uint32_t address, } static bool get_phys_addr_pmsav5(CPUARMState *env, uint32_t address, - int access_type, ARMMMUIdx mmu_idx, + MMUAccessType access_type, ARMMMUIdx mmu_idx, hwaddr *phys_ptr, int *prot, uint32_t *fsr) { int n; @@ -8437,7 +8437,7 @@ static bool get_phys_addr_pmsav5(CPUARMState *env, uint32_t address, return true; } - if (access_type == 2) { + if (access_type == MMU_INST_FETCH) { mask = env->cp15.pmsav5_insn_ap; } else { mask = env->cp15.pmsav5_data_ap; @@ -8508,7 +8508,7 @@ static bool get_phys_addr_pmsav5(CPUARMState *env, uint32_t address, * @fsr: set to the DFSR/IFSR value on failure */ static bool get_phys_addr(CPUARMState *env, target_ulong address, - int access_type, ARMMMUIdx mmu_idx, + MMUAccessType access_type, ARMMMUIdx mmu_idx, hwaddr *phys_ptr, MemTxAttrs *attrs, int *prot, target_ulong *page_size, uint32_t *fsr, ARMMMUFaultInfo *fi) @@ -8621,7 +8621,7 @@ static bool get_phys_addr(CPUARMState *env, target_ulong address, * fsr with ARM DFSR/IFSR fault register format value on failure. */ bool arm_tlb_fill(CPUState *cs, vaddr address, - int access_type, int mmu_idx, uint32_t *fsr, + MMUAccessType access_type, int mmu_idx, uint32_t *fsr, ARMMMUFaultInfo *fi) { ARMCPU *cpu = ARM_CPU(cs); From patchwork Mon Sep 4 12:25:33 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 111562 Delivered-To: patch@linaro.org Received: by 10.140.94.166 with SMTP id g35csp1467154qge; Mon, 4 Sep 2017 05:32:56 -0700 (PDT) X-Google-Smtp-Source: ADKCNb7K8K8p3hfvnSKrC7/BfHZ6mF3+T1UHJ6cggVv3qgjUQI6A54HYWsRiyBYJl49yssmbiwfg X-Received: by 10.237.63.100 with SMTP id q33mr452836qtf.114.1504528376863; Mon, 04 Sep 2017 05:32:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1504528376; cv=none; d=google.com; s=arc-20160816; b=06KSyIytfA8JML0iVLHJibzqTOmI4aLHAxr+zx72CDGZYtXSIws+jz8/bbIM87+lTG TIKys6K35vO0teVusRLYZPCBTUHAvJV71sy22cON7PUzChT7ZbmapO6iNoVpfq+k4J8A PQrjThigGT5GM6dudgXesQnHilT8WVw3dzz4RZliour26ltaJ2T4wOK21OunVvefN7Rp P+IwPG2Piyo95Y/y+yVyBYeALOZJ7E0FBYnoRHPj9HPv4LW3L/+nv7zf2V34FqmE9ank hDGrnt6HF0H1g2PuCY2cvVeTOFSf4es7Ymt8OzfDuE3JwwTmx9mYEeA0RoB3x9ux4LoH AgYg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:arc-authentication-results; bh=S2Odfl2i25A6dOMMsAtTTwgqIEYd+LErxn3LYfN4HJI=; b=yYm2Cf2wJAP08P3dXfB6LUWQogAS+FU0/Yx6DgO9NRpThX5wx5fzvdGwHh4kJy8IGz vrm6qD9VjmX2yl6fQc7kf00kCL9nxoSCDuXdnL60rhoUdQsrWcaDBzF/+vWv7BPqdnxF Otj3oVofVkMRFEmiNMa3tWJBoPH9hidq5JsDn5tnMq/23YTCvG/8vjwHmHI483Tlra+z c9/WXTyZIfaNbMqn1TYY/D/xOqWIVeKOvlLVBymtWX6tkmGEbAUxUwCcdl1KWxOQuYjb M6AFm0VTUPED1uaZ4D7D5MBSewQcnPzRim+fuvM8yaulTu6vyd5D7zJmPWCqrL5cKlf2 +2Fw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id p31si6687429qtd.105.2017.09.04.05.32.56 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 04 Sep 2017 05:32:56 -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; Authentication-Results: mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:59563 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1doqYg-0001Pg-6m for patch@linaro.org; Mon, 04 Sep 2017 08:32:54 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52301) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1doqSD-0004qS-CC for qemu-devel@nongnu.org; Mon, 04 Sep 2017 08:26:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1doqS3-0004cb-IL for qemu-devel@nongnu.org; Mon, 04 Sep 2017 08:26:13 -0400 Received: from orth.archaic.org.uk ([2001:8b0:1d0::2]:37106) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1doqS3-0004Yp-BM for qemu-devel@nongnu.org; Mon, 04 Sep 2017 08:26:03 -0400 Received: from pm215 by orth.archaic.org.uk with local (Exim 4.89) (envelope-from ) id 1doqRt-0005Pu-Rz for qemu-devel@nongnu.org; Mon, 04 Sep 2017 13:25:53 +0100 From: Peter Maydell To: qemu-devel@nongnu.org Date: Mon, 4 Sep 2017 13:25:33 +0100 Message-Id: <1504527967-29248-3-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1504527967-29248-1-git-send-email-peter.maydell@linaro.org> References: <1504527967-29248-1-git-send-email-peter.maydell@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2001:8b0:1d0::2 Subject: [Qemu-devel] [PULL 02/36] target/arm: Don't trap WFI/WFE for M profile X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 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" M profile cores can never trap on WFI or WFE instructions. Check for M profile in check_wfx_trap() to ensure this. The existing code will do the right thing for v7M cores because the hcr_el2 and scr_el3 registers will be all-zeroes and so we won't attempt to trap, but when we start setting ARM_FEATURE_V8 for v8M cores the v8A handling of SCTLR.nTWE and .nTWI will not give the right results. Signed-off-by: Peter Maydell Reviewed-by: Edgar E. Iglesias Reviewed-by: Richard Henderson Message-id: 1501692241-23310-3-git-send-email-peter.maydell@linaro.org --- target/arm/op_helper.c | 5 +++++ 1 file changed, 5 insertions(+) -- 2.7.4 diff --git a/target/arm/op_helper.c b/target/arm/op_helper.c index 2a85666..5a94a5f 100644 --- a/target/arm/op_helper.c +++ b/target/arm/op_helper.c @@ -370,6 +370,11 @@ static inline int check_wfx_trap(CPUARMState *env, bool is_wfe) int cur_el = arm_current_el(env); uint64_t mask; + if (arm_feature(env, ARM_FEATURE_M)) { + /* M profile cores can never trap WFI/WFE. */ + return 0; + } + /* If we are currently in EL0 then we need to check if SCTLR is set up for * WFx instructions being trapped to EL1. These trap bits don't exist in v7. */ From patchwork Mon Sep 4 12:25:34 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 111558 Delivered-To: patch@linaro.org Received: by 10.140.94.166 with SMTP id g35csp1463288qge; Mon, 4 Sep 2017 05:29:48 -0700 (PDT) X-Google-Smtp-Source: ADKCNb6P2QkjURiH79psvFMMtBujI2ilBPYQJEjn2W2pgSnozG/N4s5F396oSlXKMV5goTNeqwsw X-Received: by 10.200.35.123 with SMTP id b56mr500379qtb.62.1504528188767; Mon, 04 Sep 2017 05:29:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1504528188; cv=none; d=google.com; s=arc-20160816; b=z0s0HDwX+JqjvAcFDUM5uE6eakd6Gn47ISVZV2NXroXIsEcat0t62/pyJUovPCQGWg /B8icndIrOXuKEEhortO1Inkzm35bTXb3p7PU2ItuyRAV6JL3GW2s8LZBMkQs1YcAp/3 aSdZ+WMNQflgpv7Le0U8BBFTQ0cabb4LaDc+u6otMDEYRTN5vAcG5XXIt4kr4sMR1lOB M2OSL3fNnSjVwWleEvgYnhWRwY36RivD21PMSym0X3ybccosufXBfNIwRvm1B9iqUog6 Zt6KORRYCWzl307UCX+gIJYwMgJIfVrlPmThrezsdzgBoFcg9tRcOTPkql5TfmQW2z+7 PbXQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:arc-authentication-results; bh=diQP6YkW3RfeqUjZ5ueARhxaZCY1PMqm1v7qdlTSHu4=; b=iVIXvIoZbgYIIVLvdInDB1msPrwPAGl7kY/hpKZoiV2Vcx5EzY1187OU/K6aLkP8+d ChhuQ/qO1sqc1P54a+t8njeQTVAOitKn8LyIE7acC6cgv5zfQiq5VquFdtBF9cEsvRvO BUYavPhAEuzzsNzaao+1vyJHJIJ4eXPJLMSO7pX2RHag033GzQgd9QreYC/X+m5NXZ96 +FcW/8ND06WLjs6lzDvDCnfk18913QZz+yg0tFaWqUjI337xTX3C33OrNy/+rK9jRdJl 1m6PgftE3n6FTB4wnKLWchOOHcKOtVF6GIGqEv/okw6CvUqnxvP9pdfUD5zwov9LY9L0 ykww== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id a64si5461531qkf.87.2017.09.04.05.29.48 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 04 Sep 2017 05:29:48 -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; Authentication-Results: mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:59542 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1doqVe-0007Id-ED for patch@linaro.org; Mon, 04 Sep 2017 08:29:46 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52196) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1doqS9-0004o7-H9 for qemu-devel@nongnu.org; Mon, 04 Sep 2017 08:26:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1doqS2-0004bM-Mg for qemu-devel@nongnu.org; Mon, 04 Sep 2017 08:26:09 -0400 Received: from orth.archaic.org.uk ([2001:8b0:1d0::2]:37106) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1doqS2-0004Yp-Bf for qemu-devel@nongnu.org; Mon, 04 Sep 2017 08:26:02 -0400 Received: from pm215 by orth.archaic.org.uk with local (Exim 4.89) (envelope-from ) id 1doqRv-0005QN-5d for qemu-devel@nongnu.org; Mon, 04 Sep 2017 13:25:55 +0100 From: Peter Maydell To: qemu-devel@nongnu.org Date: Mon, 4 Sep 2017 13:25:34 +0100 Message-Id: <1504527967-29248-4-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1504527967-29248-1-git-send-email-peter.maydell@linaro.org> References: <1504527967-29248-1-git-send-email-peter.maydell@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2001:8b0:1d0::2 Subject: [Qemu-devel] [PULL 03/36] target/arm: Consolidate PMSA handling in get_phys_addr() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 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" Currently get_phys_addr() has PMSAv7 handling before the "is translation disabled?" check, and then PMSAv5 after it. Tidy this up by making the PMSAv5 code handle the "MPU disabled" case itself, so that we have all the PMSA code in one place. This will make adding the PMSAv8 code slightly cleaner, and also means that pre-v7 PMSA cores benefit from the MPU lookup logging that the PMSAv7 codepath had. Signed-off-by: Peter Maydell Reviewed-by: Edgar E. Iglesias Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson Message-id: 1501692241-23310-4-git-send-email-peter.maydell@linaro.org --- target/arm/helper.c | 38 ++++++++++++++++++++++---------------- 1 file changed, 22 insertions(+), 16 deletions(-) -- 2.7.4 diff --git a/target/arm/helper.c b/target/arm/helper.c index 8e148be..8190682 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -8418,6 +8418,13 @@ static bool get_phys_addr_pmsav5(CPUARMState *env, uint32_t address, uint32_t base; bool is_user = regime_is_user(env, mmu_idx); + if (regime_translation_disabled(env, mmu_idx)) { + /* MPU disabled. */ + *phys_ptr = address; + *prot = PAGE_READ | PAGE_WRITE | PAGE_EXEC; + return false; + } + *phys_ptr = address; for (n = 7; n >= 0; n--) { base = env->cp15.c6_region[n]; @@ -8567,16 +8574,20 @@ static bool get_phys_addr(CPUARMState *env, target_ulong address, } } - /* pmsav7 has special handling for when MPU is disabled so call it before - * the common MMU/MPU disabled check below. - */ - if (arm_feature(env, ARM_FEATURE_PMSA) && - arm_feature(env, ARM_FEATURE_V7)) { + if (arm_feature(env, ARM_FEATURE_PMSA)) { bool ret; *page_size = TARGET_PAGE_SIZE; - ret = get_phys_addr_pmsav7(env, address, access_type, mmu_idx, - phys_ptr, prot, fsr); - qemu_log_mask(CPU_LOG_MMU, "PMSAv7 MPU lookup for %s at 0x%08" PRIx32 + + if (arm_feature(env, ARM_FEATURE_V7)) { + /* PMSAv7 */ + ret = get_phys_addr_pmsav7(env, address, access_type, mmu_idx, + phys_ptr, prot, fsr); + } else { + /* Pre-v7 MPU */ + ret = get_phys_addr_pmsav5(env, address, access_type, mmu_idx, + phys_ptr, prot, fsr); + } + qemu_log_mask(CPU_LOG_MMU, "PMSA MPU lookup for %s at 0x%08" PRIx32 " mmu_idx %u -> %s (prot %c%c%c)\n", access_type == MMU_DATA_LOAD ? "reading" : (access_type == MMU_DATA_STORE ? "writing" : "execute"), @@ -8589,21 +8600,16 @@ static bool get_phys_addr(CPUARMState *env, target_ulong address, return ret; } + /* Definitely a real MMU, not an MPU */ + if (regime_translation_disabled(env, mmu_idx)) { - /* MMU/MPU disabled. */ + /* MMU disabled. */ *phys_ptr = address; *prot = PAGE_READ | PAGE_WRITE | PAGE_EXEC; *page_size = TARGET_PAGE_SIZE; return 0; } - if (arm_feature(env, ARM_FEATURE_PMSA)) { - /* Pre-v7 MPU */ - *page_size = TARGET_PAGE_SIZE; - return get_phys_addr_pmsav5(env, address, access_type, mmu_idx, - phys_ptr, prot, fsr); - } - if (regime_using_lpae_format(env, mmu_idx)) { return get_phys_addr_lpae(env, address, access_type, mmu_idx, phys_ptr, attrs, prot, page_size, fsr, fi); From patchwork Mon Sep 4 12:25:35 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 111557 Delivered-To: patch@linaro.org Received: by 10.140.94.166 with SMTP id g35csp1462665qge; Mon, 4 Sep 2017 05:29:16 -0700 (PDT) X-Google-Smtp-Source: ADKCNb4Th/zwwV11AdJmyv9u4kAvogF4GDQxMLXtUJZdiV6Ie5bDbz3cPEVRNs+z2nlX4qo4tQ9D X-Received: by 10.55.41.82 with SMTP id p79mr548708qkh.109.1504528156018; Mon, 04 Sep 2017 05:29:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1504528156; cv=none; d=google.com; s=arc-20160816; b=nWtsufi8XCSdN9aWhuR8VJQM1ZaWy9Muu11aDkTwluM7kuXE+rF8OXLpXLZf8W9R/1 i+BTsUjgRnp7WK9ydOsA+bsma4czm2xTN+Ay7X3MGftfDA12CQR3k+NzOKWUspAieXF2 vP77ErmETiOd/NFTeqcwyoZX/fX02Df+x5s5U/XB9q8AxqZKklbE2NFzb+CXOugw3gOe dz7TjQ3eSDvpMAgxllzKqV3dif9hNaBv1uj0kogoA/7+a9diUuoMVrRRvvAGQFgBiuko l/K5cVSSF6JZ4mBVwPtozehu3F4m5ZrNlsMtkvMMD8Tv2WGwVw9uQJt2gd642dpLvwyU bnJQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:arc-authentication-results; bh=eVoaELuzW0nSBzBFsQ3Te4/X9VQkFp1c7gkL4Ed9mHM=; b=tRr2YYAUroHEOIi64GZn4lgwAaVL4dkMTE2qNBbpqVd7oOc7i2Q3OmZfc8+6HOzStF pTSgZ6zZOwbH93LmUtyi5NPIynGgqk0L0qrz/BLYisLrfSIWAp18Xb8lBU2oDLWZZXh4 TpGkka92ZbA3oWKzqRvoskMsc1kZ0uVXjlhAycy9Owh5G7FeQXSIvjIjdANEoU8ooOfk pdKLradPGI4mXw6xfSNaBDMnuyNXflzVw2Qiq/7evZidBIKlYALbJaPdko6chAXsAQ/C 8PGuiFfKd8+jOTNuZwkFoyQdLaCv3tOBxufFrInFXpFRRmnsz5bCFE9vPJi/khurxCJP QTwQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id e14si5204732qtf.97.2017.09.04.05.29.15 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 04 Sep 2017 05:29:16 -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; Authentication-Results: mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:59540 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1doqV7-0006tV-Od for patch@linaro.org; Mon, 04 Sep 2017 08:29:13 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52159) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1doqS7-0004mx-Mw for qemu-devel@nongnu.org; Mon, 04 Sep 2017 08:26:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1doqS2-0004ad-3B for qemu-devel@nongnu.org; Mon, 04 Sep 2017 08:26:07 -0400 Received: from orth.archaic.org.uk ([2001:8b0:1d0::2]:37104) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1doqS1-0004RY-PM for qemu-devel@nongnu.org; Mon, 04 Sep 2017 08:26:01 -0400 Received: from pm215 by orth.archaic.org.uk with local (Exim 4.89) (envelope-from ) id 1doqRx-0005Qd-4H for qemu-devel@nongnu.org; Mon, 04 Sep 2017 13:25:57 +0100 From: Peter Maydell To: qemu-devel@nongnu.org Date: Mon, 4 Sep 2017 13:25:35 +0100 Message-Id: <1504527967-29248-5-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1504527967-29248-1-git-send-email-peter.maydell@linaro.org> References: <1504527967-29248-1-git-send-email-peter.maydell@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2001:8b0:1d0::2 Subject: [Qemu-devel] [PULL 04/36] target/arm: Tighten up Thumb decode where new v8M insns will be X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 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" Tighten up the T32 decoder in the places where new v8M instructions will be: * TT/TTT/TTA/TTAT are in what was nominally LDREX/STREX r15, ... which is UNPREDICTABLE: make the UNPREDICTABLE behaviour be to UNDEF * BXNS/BLXNS are distinguished from BX/BLX via the low 3 bits, which in previous architectural versions are SBZ: enforce the SBZ via UNDEF rather than ignoring it, and move the "ARCH(5)" UNDEF case up so we don't leak a TCG temporary * SG is in the encoding which would be LDRD/STRD with rn = r15; this is UNPREDICTABLE and we currently UNDEF: move this check further up the code so that we don't leak TCG temporaries in the UNDEF case and have a better place to put the SG decode. This means that if a v8M binary is accidentally run on v7M or if a test case hits something that we haven't implemented yet the behaviour will be obvious (UNDEF) rather than obscure (plough on treating it as a different instruction). In the process, add some comments about the instruction patterns at these points in the decode. Our Thumb and ARM decoders are very difficult to understand currently, but gradually adding comments like this should help to clarify what exactly has been decoded when. Signed-off-by: Peter Maydell Reviewed-by: Edgar E. Iglesias Reviewed-by: Richard Henderson Message-id: 1501692241-23310-5-git-send-email-peter.maydell@linaro.org --- target/arm/translate.c | 48 +++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 39 insertions(+), 9 deletions(-) -- 2.7.4 diff --git a/target/arm/translate.c b/target/arm/translate.c index d1a5f56..3c14cb0 100644 --- a/target/arm/translate.c +++ b/target/arm/translate.c @@ -9735,10 +9735,23 @@ static int disas_thumb2_insn(CPUARMState *env, DisasContext *s, uint16_t insn_hw abort(); case 4: if (insn & (1 << 22)) { - /* Other load/store, table branch. */ + /* 0b1110_100x_x1xx_xxxx_xxxx_xxxx_xxxx_xxxx + * - load/store doubleword, load/store exclusive, ldacq/strel, + * table branch. + */ if (insn & 0x01200000) { - /* Load/store doubleword. */ + /* 0b1110_1000_x11x_xxxx_xxxx_xxxx_xxxx_xxxx + * - load/store dual (post-indexed) + * 0b1111_1001_x10x_xxxx_xxxx_xxxx_xxxx_xxxx + * - load/store dual (literal and immediate) + * 0b1111_1001_x11x_xxxx_xxxx_xxxx_xxxx_xxxx + * - load/store dual (pre-indexed) + */ if (rn == 15) { + if (insn & (1 << 21)) { + /* UNPREDICTABLE */ + goto illegal_op; + } addr = tcg_temp_new_i32(); tcg_gen_movi_i32(addr, s->pc & ~3); } else { @@ -9772,15 +9785,18 @@ static int disas_thumb2_insn(CPUARMState *env, DisasContext *s, uint16_t insn_hw } if (insn & (1 << 21)) { /* Base writeback. */ - if (rn == 15) - goto illegal_op; tcg_gen_addi_i32(addr, addr, offset - 4); store_reg(s, rn, addr); } else { tcg_temp_free_i32(addr); } } else if ((insn & (1 << 23)) == 0) { - /* Load/store exclusive word. */ + /* 0b1110_1000_010x_xxxx_xxxx_xxxx_xxxx_xxxx + * - load/store exclusive word + */ + if (rs == 15) { + goto illegal_op; + } addr = tcg_temp_local_new_i32(); load_reg_var(s, addr, rn); tcg_gen_addi_i32(addr, addr, (insn & 0xff) << 2); @@ -11137,7 +11153,9 @@ static void disas_thumb_insn(CPUARMState *env, DisasContext *s) break; } if (insn & (1 << 10)) { - /* data processing extended or blx */ + /* 0b0100_01xx_xxxx_xxxx + * - data processing extended, branch and exchange + */ rd = (insn & 7) | ((insn >> 4) & 8); rm = (insn >> 3) & 0xf; op = (insn >> 8) & 3; @@ -11160,10 +11178,21 @@ static void disas_thumb_insn(CPUARMState *env, DisasContext *s) tmp = load_reg(s, rm); store_reg(s, rd, tmp); break; - case 3:/* branch [and link] exchange thumb register */ - tmp = load_reg(s, rm); - if (insn & (1 << 7)) { + case 3: + { + /* 0b0100_0111_xxxx_xxxx + * - branch [and link] exchange thumb register + */ + bool link = insn & (1 << 7); + + if (insn & 7) { + goto undef; + } + if (link) { ARCH(5); + } + tmp = load_reg(s, rm); + if (link) { val = (uint32_t)s->pc | 1; tmp2 = tcg_temp_new_i32(); tcg_gen_movi_i32(tmp2, val); @@ -11175,6 +11204,7 @@ static void disas_thumb_insn(CPUARMState *env, DisasContext *s) } break; } + } break; } From patchwork Mon Sep 4 12:25:36 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 111554 Delivered-To: patch@linaro.org Received: by 10.140.94.166 with SMTP id g35csp1460106qge; Mon, 4 Sep 2017 05:26:47 -0700 (PDT) X-Google-Smtp-Source: ADKCNb7TkgqRVWnq7492nnzsV1rFQq+Nj5Puf/BVIVxxxVWxQr7+WdTVbkiE1cLNXGiqW5AveOh6 X-Received: by 10.55.163.195 with SMTP id m186mr553064qke.304.1504528007914; Mon, 04 Sep 2017 05:26:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1504528007; cv=none; d=google.com; s=arc-20160816; b=fo41PA9nH2Oq+HvpPQoPmGrqMWIMlcPrrj196Sr7uciZTuq2eCfH2u9mYycMtVlxvT EQoEuhNkAxq40sUlkajzyBSVSiak9dYv6JZULcxGiaKWxgNPtKPg24BAd9a1cj4EAzH7 Dzd51dCZQfUU8+G3snHMPm4TPn08A5/RD2JnLGfPn9suz4WzyMxDR6enLsHvRkE3uT8A 6xkFplc6tx0rPZTUDevmHq4yxdAS+CcYfcTVxhykmhM9vpC7ziWoR1PRKihjl1S2tMUx 9yCTNlSbbqrxuo0BDisNqvnj81riU2/kREp3CLqfVGXWJCS/rUGwwuCAG5oeVnQc+EN3 HJKw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:arc-authentication-results; bh=E1heGhlw4hV5GcJSu3I2YLcYLRK+G9ZI8wsUKBk2bWw=; b=FUazPXcnFDL9J0rgbVWd6FdzfJyXu+b4Gn2Y0XMMiuaqNKxHl3xlbGJXN8YMH4DL3a 5Ge2Zt+nTwFM+uiSUXlLMMyg2bIXhzDsm8zN1hoZFQubW5G9Av5UFfz56huXyXkXSbGr CwPnDACYhOYDivFFvN8Mq4EAtjJuRX0WSEp/jDIRjnDy3EFietHgpStuSroIUgMptKEK dL7Hgxp2dmdyf60ZEQLD1AbkfGtnksdzZ2DDabsloLid1AJnGrGzx/0uWKuG1Q5+Osjj irDXWwpxE6/rR/FfXYGfqFe95oqCYPcWas6pIi3mSXPLzltAHy8LiTVSpXEHTEvcmud3 FQaA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id y18si6923595qtf.386.2017.09.04.05.26.47 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 04 Sep 2017 05:26:47 -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; Authentication-Results: mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:59523 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1doqSj-0004sl-Pl for patch@linaro.org; Mon, 04 Sep 2017 08:26:45 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52113) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1doqS5-0004lV-HT for qemu-devel@nongnu.org; Mon, 04 Sep 2017 08:26:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1doqS1-0004Z5-1m for qemu-devel@nongnu.org; Mon, 04 Sep 2017 08:26:05 -0400 Received: from orth.archaic.org.uk ([2001:8b0:1d0::2]:37104) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1doqS0-0004RY-SH for qemu-devel@nongnu.org; Mon, 04 Sep 2017 08:26:00 -0400 Received: from pm215 by orth.archaic.org.uk with local (Exim 4.89) (envelope-from ) id 1doqRz-0005R8-0O for qemu-devel@nongnu.org; Mon, 04 Sep 2017 13:25:59 +0100 From: Peter Maydell To: qemu-devel@nongnu.org Date: Mon, 4 Sep 2017 13:25:36 +0100 Message-Id: <1504527967-29248-6-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1504527967-29248-1-git-send-email-peter.maydell@linaro.org> References: <1504527967-29248-1-git-send-email-peter.maydell@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2001:8b0:1d0::2 Subject: [Qemu-devel] [PULL 05/36] hw/intc/armv7m_nvic.c: Remove out of date comment X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 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" Remove an out of date comment which says there's only one item in the NVIC container region -- we put systick into its own device object a while back and so now there are two things in the container. Signed-off-by: Peter Maydell Reviewed-by: Edgar E. Iglesias Reviewed-by: Richard Henderson Message-id: 1501692241-23310-6-git-send-email-peter.maydell@linaro.org --- hw/intc/armv7m_nvic.c | 4 ---- 1 file changed, 4 deletions(-) -- 2.7.4 diff --git a/hw/intc/armv7m_nvic.c b/hw/intc/armv7m_nvic.c index 323e2d4..2e8166a 100644 --- a/hw/intc/armv7m_nvic.c +++ b/hw/intc/armv7m_nvic.c @@ -1036,10 +1036,6 @@ static void armv7m_nvic_realize(DeviceState *dev, Error **errp) * 0xd00..0xd3c - SCS registers * 0xd40..0xeff - Reserved or Not implemented * 0xf00 - STIR - * - * At the moment there is only one thing in the container region, - * but we leave it in place to allow us to pull systick out into - * its own device object later. */ memory_region_init(&s->container, OBJECT(s), "nvic", 0x1000); /* The system register region goes at the bottom of the priority From patchwork Mon Sep 4 12:25:37 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 111561 Delivered-To: patch@linaro.org Received: by 10.140.94.166 with SMTP id g35csp1466653qge; Mon, 4 Sep 2017 05:32:31 -0700 (PDT) X-Google-Smtp-Source: ADKCNb4fpufZFi2rQf9+jOAfUmmqq3FYAiYczAcIQjHJcXiqucpVOoCFL5DlnNNAdgj5nZn/tjm1 X-Received: by 10.200.34.207 with SMTP id g15mr472814qta.20.1504528351263; Mon, 04 Sep 2017 05:32:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1504528351; cv=none; d=google.com; s=arc-20160816; b=ZlVzAkJJj0RUSZhRvhdXGEcHYI9jYY73RkiDK9BUrrII47xFAH8jpZWHZsem+Wqemb ohbipCh2CCLrsByZDcx2zx/uwhQla8mu0CrTCiNqHwNvD+WXAijzcGyqRQv7Hx06IprB iB09cJpvhhJGU0hXZh1fEAdodLmyt5TDIJNgUdBEX5G2P4AvU55wvRC0Utel4ZCU9TTv fdf0AD1HQ8h6RA6VjMtZG6DmkFA6l/44WCvTj06fR5kTcfCo+zllDqsRzgig9d3RVFKj O4VcpbbQRhYINYglNShEz1rzwFBu5KjE4Jb/42NaCmjEbgHHlT26QZ9SlGLYUD/cBM3i vKQQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:arc-authentication-results; bh=2dDTniYGM2fJgA1yp5afUvuXkipb5aW2HiBvxxu2XNA=; b=l3iqDYE9nRUa6uBsBheKTgHB3hMqCGOopbjKMUgajdfRRbijTBvoQEI9W0My26FfMJ y0rEF5j+HMEY8GQtuxBFDoQ+0yvhwka0Onh7H+JWh6RLoyrkQh/LmZ/doJw9K8NXP3ar F4/ARiUs1owK08X1lzWytecs2+sDEKVclg4K1o6h0AGUYDGc2IZYHaLEN65E3VWvcnR1 Nj6v8DWfaJmQy/Lp5GDfaMHzqgtppoImbq48sRGwuu4nhjQc0xqG6uAeie0hagK5oPI5 HaZX/5kWfK79Ho0pfA1DRILQxBh/SqqY3/iL5p1myUuKV8a5+Cr/XdeTan1qdCmNLOt7 TvVA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id d200si841674qkb.328.2017.09.04.05.32.30 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 04 Sep 2017 05:32:31 -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; Authentication-Results: mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:59561 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1doqYH-00013H-3y for patch@linaro.org; Mon, 04 Sep 2017 08:32:29 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52243) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1doqSA-0004oz-Tq for qemu-devel@nongnu.org; Mon, 04 Sep 2017 08:26:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1doqS1-0004Zt-Jz for qemu-devel@nongnu.org; Mon, 04 Sep 2017 08:26:10 -0400 Received: from orth.archaic.org.uk ([2001:8b0:1d0::2]:37106) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1doqS1-0004Yp-Dm for qemu-devel@nongnu.org; Mon, 04 Sep 2017 08:26:01 -0400 Received: from pm215 by orth.archaic.org.uk with local (Exim 4.89) (envelope-from ) id 1doqS0-0005RQ-F3 for qemu-devel@nongnu.org; Mon, 04 Sep 2017 13:26:00 +0100 From: Peter Maydell To: qemu-devel@nongnu.org Date: Mon, 4 Sep 2017 13:25:37 +0100 Message-Id: <1504527967-29248-7-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1504527967-29248-1-git-send-email-peter.maydell@linaro.org> References: <1504527967-29248-1-git-send-email-peter.maydell@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2001:8b0:1d0::2 Subject: [Qemu-devel] [PULL 06/36] target/arm: Remove incorrect comment about MPU_CTRL X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 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" Remove the comment that claims that some MPU_CTRL bits are stored in sctlr_el[1]. This has never been true since MPU_CTRL was added in commit 29c483a50607 -- the comment is a leftover from Michael Davidsaver's original implementation, which I modified not to use sctlr_el[1]; I forgot to delete the comment then. Signed-off-by: Peter Maydell Reviewed-by: Edgar E. Iglesias Reviewed-by: Richard Henderson Message-id: 1501692241-23310-7-git-send-email-peter.maydell@linaro.org --- target/arm/cpu.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.7.4 diff --git a/target/arm/cpu.h b/target/arm/cpu.h index 5932ef1..2f2aa87 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -416,7 +416,7 @@ typedef struct CPUARMState { uint32_t dfsr; /* Debug Fault Status Register */ uint32_t mmfar; /* MemManage Fault Address */ uint32_t bfar; /* BusFault Address */ - unsigned mpu_ctrl; /* MPU_CTRL (some bits kept in sctlr_el[1]) */ + unsigned mpu_ctrl; /* MPU_CTRL */ int exception; } v7m; From patchwork Mon Sep 4 12:25:38 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 111556 Delivered-To: patch@linaro.org Received: by 10.140.94.166 with SMTP id g35csp1462265qge; Mon, 4 Sep 2017 05:28:53 -0700 (PDT) X-Google-Smtp-Source: ADKCNb4K+aNYeKelCnLxrNIZUeUAI7EeTJABIEnddBCISuitGraUWrv8HV38Tqu21dl+HI6yEYKy X-Received: by 10.55.22.146 with SMTP id 18mr619186qkw.112.1504528133813; Mon, 04 Sep 2017 05:28:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1504528133; cv=none; d=google.com; s=arc-20160816; b=shOk8cAut+kyAorUPDCZ7gDVY//0Bais4v/YG1/M+LQeh69pMxdWdrYowKV9T2swq1 BPEORpxKJKVW+o0TgJU27M/FpYFMfiYZ3P0vI4Lk2V3NKnfRbwxis2OIy3GEMv1xQqgF pnriypDksUCnQy5dDNoo1IsO6/7kDdgSxIil9Z1kdtpe65Vd52UH8sQ5cHM9UH2Fr8dM jtn6zqOvUBnDcS/EzKO9tV40ts/ZPlCIifdDm1Pvbdd9ppfZIBuY2BjmS4k6t6NLDFeH E+5Tv4Z9jASECeNI+1rXLtBTanShNkKYZFFy7lykw64GVjBiryJwZrXDk4FmaJbki6dd C8Zw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:arc-authentication-results; bh=otutnf2lFyt98g71qsrNyLn9pf6B6WwDwVagZZSsBjI=; b=n3PxC9zT01cTATzqj9Wro9oWbyHDTFu6kqb22QqCzVATrxXC26NosgaAl7CbNymcMs yfsIgyt8sxJIdYmQQkzotKYhb/9oRY61yd3DW71OtbsoXZ0ghrwhn5CZaLk8lxZQR997 vTW7E1obyT2Fd1PxvHD0TqvRbFaFeIogrjuXCJ+o2abWxqQvqsi27FFaioWQMnMnn84E U0iKsa4C6WePCmmwUUxlBV+iU59IgViVDwX5FOrxkZltsiQ05b7YUTI5eF8Xuvb98XiS sJHalKmJ3LwrAqNXZiYC+O0JV9JHYC4gNb75FdtVA43wgCFhBG8yuKu8J65TF7vS8xFa u10A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id n25si485254qtb.48.2017.09.04.05.28.53 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 04 Sep 2017 05:28:53 -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; Authentication-Results: mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:59531 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1doqUl-0006M2-NK for patch@linaro.org; Mon, 04 Sep 2017 08:28:51 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52236) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1doqSA-0004ou-P3 for qemu-devel@nongnu.org; Mon, 04 Sep 2017 08:26:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1doqS3-0004bv-1B for qemu-devel@nongnu.org; Mon, 04 Sep 2017 08:26:10 -0400 Received: from orth.archaic.org.uk ([2001:8b0:1d0::2]:37104) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1doqS2-0004RY-Q0 for qemu-devel@nongnu.org; Mon, 04 Sep 2017 08:26:02 -0400 Received: from pm215 by orth.archaic.org.uk with local (Exim 4.89) (envelope-from ) id 1doqS1-0005Ri-Gj for qemu-devel@nongnu.org; Mon, 04 Sep 2017 13:26:01 +0100 From: Peter Maydell To: qemu-devel@nongnu.org Date: Mon, 4 Sep 2017 13:25:38 +0100 Message-Id: <1504527967-29248-8-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1504527967-29248-1-git-send-email-peter.maydell@linaro.org> References: <1504527967-29248-1-git-send-email-peter.maydell@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2001:8b0:1d0::2 Subject: [Qemu-devel] [PULL 07/36] target/arm: Fix outdated comment about exception exit X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 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" When we switched our handling of exception exit to detect the magic addresses at translate time rather than via a do_unassigned_access hook, we forgot to update a comment; correct the omission. Signed-off-by: Peter Maydell Reviewed-by: Edgar E. Iglesias Reviewed-by: Richard Henderson Message-id: 1501692241-23310-8-git-send-email-peter.maydell@linaro.org --- target/arm/helper.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.7.4 diff --git a/target/arm/helper.c b/target/arm/helper.c index 8190682..2fb0202 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -6138,7 +6138,7 @@ static void do_v7m_exception_exit(ARMCPU *cpu) bool rettobase = false; /* We can only get here from an EXCP_EXCEPTION_EXIT, and - * arm_v7m_do_unassigned_access() enforces the architectural rule + * gen_bx_excret() enforces the architectural rule * that jumps to magic addresses don't have magic behaviour unless * we're in Handler mode (compare pseudocode BXWritePC()). */ From patchwork Mon Sep 4 12:25:39 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 111559 Delivered-To: patch@linaro.org Received: by 10.140.94.166 with SMTP id g35csp1465990qge; Mon, 4 Sep 2017 05:31:53 -0700 (PDT) X-Google-Smtp-Source: ADKCNb41DjhGILdy0rfP4AuDfYlHX4kjGxUqeX4F3n47q9ICHbmxNRGtci42jAC1zRXOHFScAxWj X-Received: by 10.200.38.229 with SMTP id 34mr290885qtp.319.1504528313608; Mon, 04 Sep 2017 05:31:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1504528313; cv=none; d=google.com; s=arc-20160816; b=JPInFURz2eIhkSWwVFVKIGhI1QjA8ToQ4k7+IQMG27THtv0iDiLBQ/0GbQ8/4I4v81 SyTeapPg174LeuNZl/3lxbXi7Gfs7fB0DV82j9kfLUKIpvPFAgR/OlZVP2aK1TSL59+i 93N5/2uGaA3mA6GkG+0grX7eMgm7n+TWUGtw0JfoflZP9jLuX4V9EUYotyCFPefebuuX Pd1O42KfWm8HrjQWxBRT4BiCfyE4d03pghJOL1h93JPmAoqFd8tkfBjJ+szC38rhZCBM 6ngxFhofhj/wRMOA4VS86SZKgjKuq/2Arye+Gu2RfoLM9ofD3l3iyioYwq+xN2VbC9NW uemA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:arc-authentication-results; bh=BSlrp5yJa7YD1Bg7T5wZYdxeHfujyY8++6En8w9XcX8=; b=TruQyazKJYDawl6U4Isc8ZnVeAvc4rbIVBMXBOpJUKPY9cmCWHHyGs/oGm+MdnQMkd xVdqZKZXBA2+X1/9+MPupf+QqE7aDo1U5K8ms8Hod6ByRWJIj5dlITO/b4lYnSrtJZle Ht21wq5sXq5rstFOXCgbTVuGXzCLOVdDRCMGaNyCDiW82Doe9KNBSGSqfFv198GHiTR0 GIJpZU/xzOTNrBga0oh1C1Gyi/3Qr8W9NkvJ9kBAk2H6/4rRCV6c+mIRe9JShPjNujzv NxesVx421haHqaPPL6fJti+GlgQPIY5Z6Ei+9Z+1UzEDyqch9ejMtw73C1vinQySk9UO rY1Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id m16si904199qtf.22.2017.09.04.05.31.53 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 04 Sep 2017 05:31:53 -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; Authentication-Results: mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:59557 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1doqXf-0000NN-Eu for patch@linaro.org; Mon, 04 Sep 2017 08:31:51 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52318) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1doqSE-0004qu-4N for qemu-devel@nongnu.org; Mon, 04 Sep 2017 08:26:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1doqS4-0004dQ-4m for qemu-devel@nongnu.org; Mon, 04 Sep 2017 08:26:14 -0400 Received: from orth.archaic.org.uk ([2001:8b0:1d0::2]:37108) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1doqS3-0004cC-Sv for qemu-devel@nongnu.org; Mon, 04 Sep 2017 08:26:04 -0400 Received: from pm215 by orth.archaic.org.uk with local (Exim 4.89) (envelope-from ) id 1doqS2-0005SG-S3 for qemu-devel@nongnu.org; Mon, 04 Sep 2017 13:26:02 +0100 From: Peter Maydell To: qemu-devel@nongnu.org Date: Mon, 4 Sep 2017 13:25:39 +0100 Message-Id: <1504527967-29248-9-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1504527967-29248-1-git-send-email-peter.maydell@linaro.org> References: <1504527967-29248-1-git-send-email-peter.maydell@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2001:8b0:1d0::2 Subject: [Qemu-devel] [PULL 08/36] target/arm: Define and use XPSR bit masks X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 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" The M profile XPSR is almost the same format as the A profile CPSR, but not quite. Define some XPSR_* macros and use them where we definitely dealing with an XPSR rather than reusing the CPSR ones. Signed-off-by: Peter Maydell Reviewed-by: Edgar E. Iglesias Reviewed-by: Richard Henderson Message-id: 1501692241-23310-9-git-send-email-peter.maydell@linaro.org --- target/arm/cpu.h | 38 ++++++++++++++++++++++++++++---------- target/arm/helper.c | 15 ++++++++------- 2 files changed, 36 insertions(+), 17 deletions(-) -- 2.7.4 diff --git a/target/arm/cpu.h b/target/arm/cpu.h index 2f2aa87..0b9f937 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -882,6 +882,22 @@ void pmccntr_sync(CPUARMState *env); /* Mask of bits which may be set by exception return copying them from SPSR */ #define CPSR_ERET_MASK (~CPSR_RESERVED) +/* Bit definitions for M profile XPSR. Most are the same as CPSR. */ +#define XPSR_EXCP 0x1ffU +#define XPSR_SPREALIGN (1U << 9) /* Only set in exception stack frames */ +#define XPSR_IT_2_7 CPSR_IT_2_7 +#define XPSR_GE CPSR_GE +#define XPSR_SFPA (1U << 20) /* Only set in exception stack frames */ +#define XPSR_T (1U << 24) /* Not the same as CPSR_T ! */ +#define XPSR_IT_0_1 CPSR_IT_0_1 +#define XPSR_Q CPSR_Q +#define XPSR_V CPSR_V +#define XPSR_C CPSR_C +#define XPSR_Z CPSR_Z +#define XPSR_N CPSR_N +#define XPSR_NZCV CPSR_NZCV +#define XPSR_IT CPSR_IT + #define TTBCR_N (7U << 0) /* TTBCR.EAE==0 */ #define TTBCR_T0SZ (7U << 0) /* TTBCR.EAE==1 */ #define TTBCR_PD0 (1U << 4) @@ -986,26 +1002,28 @@ static inline uint32_t xpsr_read(CPUARMState *env) /* Set the xPSR. Note that some bits of mask must be all-set or all-clear. */ static inline void xpsr_write(CPUARMState *env, uint32_t val, uint32_t mask) { - if (mask & CPSR_NZCV) { - env->ZF = (~val) & CPSR_Z; + if (mask & XPSR_NZCV) { + env->ZF = (~val) & XPSR_Z; env->NF = val; env->CF = (val >> 29) & 1; env->VF = (val << 3) & 0x80000000; } - if (mask & CPSR_Q) - env->QF = ((val & CPSR_Q) != 0); - if (mask & (1 << 24)) - env->thumb = ((val & (1 << 24)) != 0); - if (mask & CPSR_IT_0_1) { + if (mask & XPSR_Q) { + env->QF = ((val & XPSR_Q) != 0); + } + if (mask & XPSR_T) { + env->thumb = ((val & XPSR_T) != 0); + } + if (mask & XPSR_IT_0_1) { env->condexec_bits &= ~3; env->condexec_bits |= (val >> 25) & 3; } - if (mask & CPSR_IT_2_7) { + if (mask & XPSR_IT_2_7) { env->condexec_bits &= 3; env->condexec_bits |= (val >> 8) & 0xfc; } - if (mask & 0x1ff) { - env->v7m.exception = val & 0x1ff; + if (mask & XPSR_EXCP) { + env->v7m.exception = val & XPSR_EXCP; } } diff --git a/target/arm/helper.c b/target/arm/helper.c index 2fb0202..439ad86 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -6114,7 +6114,7 @@ static void v7m_push_stack(ARMCPU *cpu) /* Align stack pointer if the guest wants that */ if ((env->regs[13] & 4) && (env->v7m.ccr & R_V7M_CCR_STKALIGN_MASK)) { env->regs[13] -= 4; - xpsr |= 0x200; + xpsr |= XPSR_SPREALIGN; } /* Switch to the handler mode. */ v7m_push(env, xpsr); @@ -6239,10 +6239,11 @@ static void do_v7m_exception_exit(ARMCPU *cpu) env->regs[15] &= ~1U; } xpsr = v7m_pop(env); - xpsr_write(env, xpsr, 0xfffffdff); + xpsr_write(env, xpsr, ~XPSR_SPREALIGN); /* Undo stack alignment. */ - if (xpsr & 0x200) + if (xpsr & XPSR_SPREALIGN) { env->regs[13] |= 4; + } /* The restored xPSR exception field will be zero if we're * resuming in Thread mode. If that doesn't match what the @@ -8688,10 +8689,10 @@ uint32_t HELPER(v7m_mrs)(CPUARMState *env, uint32_t reg) case 0 ... 7: /* xPSR sub-fields */ mask = 0; if ((reg & 1) && el) { - mask |= 0x000001ff; /* IPSR (unpriv. reads as zero) */ + mask |= XPSR_EXCP; /* IPSR (unpriv. reads as zero) */ } if (!(reg & 4)) { - mask |= 0xf8000000; /* APSR */ + mask |= XPSR_NZCV | XPSR_Q; /* APSR */ } /* EPSR reads as zero */ return xpsr_read(env) & mask; @@ -8749,10 +8750,10 @@ void HELPER(v7m_msr)(CPUARMState *env, uint32_t maskreg, uint32_t val) uint32_t apsrmask = 0; if (mask & 8) { - apsrmask |= 0xf8000000; /* APSR NZCVQ */ + apsrmask |= XPSR_NZCV | XPSR_Q; } if ((mask & 4) && arm_feature(env, ARM_FEATURE_THUMB_DSP)) { - apsrmask |= 0x000f0000; /* APSR GE[3:0] */ + apsrmask |= XPSR_GE; } xpsr_write(env, val, apsrmask); } From patchwork Mon Sep 4 12:25:40 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 111563 Delivered-To: patch@linaro.org Received: by 10.140.94.166 with SMTP id g35csp1469630qge; Mon, 4 Sep 2017 05:35:14 -0700 (PDT) X-Google-Smtp-Source: ADKCNb5x/6iJPgmEVztVNTFmeKBj70XrnKa7THxJT8wZcxdolA8/VW1r9+3itUnk/CSzWRioGGE1 X-Received: by 10.55.114.194 with SMTP id n185mr658603qkc.180.1504528514871; Mon, 04 Sep 2017 05:35:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1504528514; cv=none; d=google.com; s=arc-20160816; b=N1t44zSw5uqb1VuHYEVsYA8D1dIzr65vrpRmlmyz3Q3eDq4pCfphNjPP3qSSwrAInd L76vTV7Vwtl3P1nh2+fpO5sME5yM7RujqOICyXYq78gcrynFv5TwsyZavHcV5IFHbIdE id+EOUFeKBVFJdR+UtIAc8Rec0i8pKIM9v989fuo48NJG+mG15wYdpkf+Fgw3jccWrh5 nLRLxZ4hshwJ/fQmVRX8JLbYs/NsxEjoZ8Grd+zY5JbpgoabAhT9WcMtxIMQr1fS0EIZ 6zH5+uGa3h3gXQo6UeHv07l6Hwp/QXaaTKawi0pnMVKqMKgS6+e6GK2Wm9E/OfGtDDnr z/8g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:arc-authentication-results; bh=MBsym5d/78rArNvv8k1hNt1zxWaxm0nqbk7To0l1Mew=; b=BfwnoUB9Hvw1jEu4CqhzkxYl7p0ytNBlrGKHARNQ/7IxMdWnCEBQxyD74rijqIGfVB bcIAf0e4oUs3B9wCcWTTUc0smVR34FIUOAf741148ZSKEJypwMomz4jbpCcO0176BVYd DU29L8U3tQ6hDCmQJ0uzZSrxH63+tEISKJMGV9X5nE1nfZLp6GjAI5C4XF6/C3Ozx4vG c5aGURu4njhZqStZCABqXl9rF2LEI1bwfyHxquCG+xkMU18OmAJdjBuDKGWnzOuy//6n OGRsSallqj3miiXgSYEsC5n9G6qiZIAi1u+bRk2PBXb0Nph3137u/MW47TuW3lVONIKT cD4w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id w39si5192476qtb.121.2017.09.04.05.35.14 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 04 Sep 2017 05:35:14 -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; Authentication-Results: mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:59570 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1doqau-0002ib-Ig for patch@linaro.org; Mon, 04 Sep 2017 08:35:12 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52329) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1doqSE-0004rN-WD for qemu-devel@nongnu.org; Mon, 04 Sep 2017 08:26:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1doqS5-0004eV-5b for qemu-devel@nongnu.org; Mon, 04 Sep 2017 08:26:14 -0400 Received: from orth.archaic.org.uk ([2001:8b0:1d0::2]:37108) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1doqS4-0004cC-RX for qemu-devel@nongnu.org; Mon, 04 Sep 2017 08:26:05 -0400 Received: from pm215 by orth.archaic.org.uk with local (Exim 4.89) (envelope-from ) id 1doqS3-0005Sl-Ru for qemu-devel@nongnu.org; Mon, 04 Sep 2017 13:26:03 +0100 From: Peter Maydell To: qemu-devel@nongnu.org Date: Mon, 4 Sep 2017 13:25:40 +0100 Message-Id: <1504527967-29248-10-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1504527967-29248-1-git-send-email-peter.maydell@linaro.org> References: <1504527967-29248-1-git-send-email-peter.maydell@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2001:8b0:1d0::2 Subject: [Qemu-devel] [PULL 09/36] target/arm: Don't store M profile PRIMASK and FAULTMASK in daif X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 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" We currently store the M profile CPU register state PRIMASK and FAULTMASK in the daif field of the CPU state in its I and F bits. This is a legacy from the original implementation, which tried to share the cpu_exec_interrupt code between A profile and M profile. We've since separated out the two cases because they are significantly different, so now there is no common code between M and A profile which looks at env->daif: all the uses are either in A-only or M-only code paths. Sharing the state fields now is just confusing, and will make things awkward when we implement v8M, where the PRIMASK and FAULTMASK registers are banked between security states. Switch M profile over to using v7m.faultmask and v7m.primask fields for these registers. Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson Message-id: 1501692241-23310-10-git-send-email-peter.maydell@linaro.org --- target/arm/cpu.h | 4 +++- hw/intc/armv7m_nvic.c | 4 ++-- target/arm/cpu.c | 5 ----- target/arm/helper.c | 18 +++++------------- target/arm/machine.c | 33 +++++++++++++++++++++++++++++++++ 5 files changed, 43 insertions(+), 21 deletions(-) -- 2.7.4 diff --git a/target/arm/cpu.h b/target/arm/cpu.h index 0b9f937..8ef552a 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -418,6 +418,8 @@ typedef struct CPUARMState { uint32_t bfar; /* BusFault Address */ unsigned mpu_ctrl; /* MPU_CTRL */ int exception; + uint32_t primask; + uint32_t faultmask; } v7m; /* Information associated with an exception about to be taken: @@ -2178,7 +2180,7 @@ static inline int cpu_mmu_index(CPUARMState *env, bool ifetch) * we're in a HardFault or NMI handler. */ if ((env->v7m.exception > 0 && env->v7m.exception <= 3) - || env->daif & PSTATE_F) { + || env->v7m.faultmask) { return arm_to_core_mmu_idx(ARMMMUIdx_MNegPri); } diff --git a/hw/intc/armv7m_nvic.c b/hw/intc/armv7m_nvic.c index 2e8166a..343bc16 100644 --- a/hw/intc/armv7m_nvic.c +++ b/hw/intc/armv7m_nvic.c @@ -167,9 +167,9 @@ static inline int nvic_exec_prio(NVICState *s) CPUARMState *env = &s->cpu->env; int running; - if (env->daif & PSTATE_F) { /* FAULTMASK */ + if (env->v7m.faultmask) { running = -1; - } else if (env->daif & PSTATE_I) { /* PRIMASK */ + } else if (env->v7m.primask) { running = 0; } else if (env->v7m.basepri > 0) { running = env->v7m.basepri & nvic_gprio_mask(s); diff --git a/target/arm/cpu.c b/target/arm/cpu.c index 05c038b..b241a63 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -185,11 +185,6 @@ static void arm_cpu_reset(CPUState *s) uint32_t initial_pc; /* Loaded from 0x4 */ uint8_t *rom; - /* For M profile we store FAULTMASK and PRIMASK in the - * PSTATE F and I bits; these are both clear at reset. - */ - env->daif &= ~(PSTATE_I | PSTATE_F); - /* The reset value of this bit is IMPDEF, but ARM recommends * that it resets to 1, so QEMU always does that rather than making * it dependent on CPU model. diff --git a/target/arm/helper.c b/target/arm/helper.c index 439ad86..9410856 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -6167,7 +6167,7 @@ static void do_v7m_exception_exit(ARMCPU *cpu) if (env->v7m.exception != ARMV7M_EXCP_NMI) { /* Auto-clear FAULTMASK on return from other than NMI */ - env->daif &= ~PSTATE_F; + env->v7m.faultmask = 0; } switch (armv7m_nvic_complete_irq(env->nvic, env->v7m.exception)) { @@ -8713,12 +8713,12 @@ uint32_t HELPER(v7m_mrs)(CPUARMState *env, uint32_t reg) return (env->v7m.control & R_V7M_CONTROL_SPSEL_MASK) ? env->regs[13] : env->v7m.other_sp; case 16: /* PRIMASK */ - return (env->daif & PSTATE_I) != 0; + return env->v7m.primask; case 17: /* BASEPRI */ case 18: /* BASEPRI_MAX */ return env->v7m.basepri; case 19: /* FAULTMASK */ - return (env->daif & PSTATE_F) != 0; + return env->v7m.faultmask; default: qemu_log_mask(LOG_GUEST_ERROR, "Attempt to read unknown special" " register %d\n", reg); @@ -8773,11 +8773,7 @@ void HELPER(v7m_msr)(CPUARMState *env, uint32_t maskreg, uint32_t val) } break; case 16: /* PRIMASK */ - if (val & 1) { - env->daif |= PSTATE_I; - } else { - env->daif &= ~PSTATE_I; - } + env->v7m.primask = val & 1; break; case 17: /* BASEPRI */ env->v7m.basepri = val & 0xff; @@ -8788,11 +8784,7 @@ void HELPER(v7m_msr)(CPUARMState *env, uint32_t maskreg, uint32_t val) env->v7m.basepri = val; break; case 19: /* FAULTMASK */ - if (val & 1) { - env->daif |= PSTATE_F; - } else { - env->daif &= ~PSTATE_F; - } + env->v7m.faultmask = val & 1; break; case 20: /* CONTROL */ /* Writing to the SPSEL bit only has an effect if we are in diff --git a/target/arm/machine.c b/target/arm/machine.c index 1f66da4..2fb4b762 100644 --- a/target/arm/machine.c +++ b/target/arm/machine.c @@ -97,6 +97,17 @@ static bool m_needed(void *opaque) return arm_feature(env, ARM_FEATURE_M); } +static const VMStateDescription vmstate_m_faultmask_primask = { + .name = "cpu/m/faultmask-primask", + .version_id = 1, + .minimum_version_id = 1, + .fields = (VMStateField[]) { + VMSTATE_UINT32(env.v7m.faultmask, ARMCPU), + VMSTATE_UINT32(env.v7m.primask, ARMCPU), + VMSTATE_END_OF_LIST() + } +}; + static const VMStateDescription vmstate_m = { .name = "cpu/m", .version_id = 4, @@ -115,6 +126,10 @@ static const VMStateDescription vmstate_m = { VMSTATE_UINT32(env.v7m.mpu_ctrl, ARMCPU), VMSTATE_INT32(env.v7m.exception, ARMCPU), VMSTATE_END_OF_LIST() + }, + .subsections = (const VMStateDescription*[]) { + &vmstate_m_faultmask_primask, + NULL } }; @@ -201,6 +216,24 @@ static int get_cpsr(QEMUFile *f, void *opaque, size_t size, CPUARMState *env = &cpu->env; uint32_t val = qemu_get_be32(f); + if (arm_feature(env, ARM_FEATURE_M)) { + /* If the I or F bits are set then this is a migration from + * an old QEMU which still stored the M profile FAULTMASK + * and PRIMASK in env->daif. Set v7m.faultmask and v7m.primask + * accordingly, and then clear the bits so they don't confuse + * cpsr_write(). For a new QEMU, the bits here will always be + * clear, and the data is transferred using the + * vmstate_m_faultmask_primask subsection. + */ + if (val & CPSR_F) { + env->v7m.faultmask = 1; + } + if (val & CPSR_I) { + env->v7m.primask = 1; + } + val &= ~(CPSR_F | CPSR_I); + } + env->aarch64 = ((val & PSTATE_nRW) == 0); if (is_a64(env)) { From patchwork Mon Sep 4 12:25:41 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 111570 Delivered-To: patch@linaro.org Received: by 10.140.94.166 with SMTP id g35csp1475830qge; Mon, 4 Sep 2017 05:40:53 -0700 (PDT) X-Google-Smtp-Source: ADKCNb7lsbDLvRElX/m4fvjeZKfuSneDMIAnOX/BYu7SUqCc0ig4BwNFkqpHF5eobw2ZAKfAPT2o X-Received: by 10.200.56.238 with SMTP id g43mr382985qtc.249.1504528853079; Mon, 04 Sep 2017 05:40:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1504528853; cv=none; d=google.com; s=arc-20160816; b=rMN7JgED/xjo+kzLi+xKSCt3ebmXPmv/7SewlG8dKI2akyiLtkHswF+DJZPPgwuzZg V75gbmJ9Kt4A9mnGEt4cPmWQnn4FS7/UQzG/09ZTDpDVUMoOP+LcYpmFZkTq5PnSKUxL oUWy3DZ9mIs3PCgTRYBYjFqD6UAzlgmLTre1JMgseDTAprpjkZDZtJ4ohvon48e2WB6R FiM5YYKwW0ln3ADUFoF4/fltKDWakNj4PDlWMNJVLO0F4rBlFDPfu2suUe5tj30J/Dck 4UsLpNuiQX/OhNMvk1OR73rBewdFaF5i/gHg+btia+DDKrr6TuoKuDHj+oJC7YQc2xvz kM2Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:arc-authentication-results; bh=ptbOltEtqXEs1MEv/IEaRE/QjGZyuSdVMrTWsyUsj4g=; b=Ya+m2kqvF/vEe7JkNNfpGQcvawZoMNDKuFszRPG5LRJb+ID6ZnfBdsbiCY0r6GD7hm YTbxRAC6DoKfqN5lcDa4T6pISLNLk8JU4JjWnrriK0u5xTEV/MF2wKJGP27ffNmvMhkM qgAITn8l3IK/YAVKmYTGFs391Mi8dV5C00frVvmwa9xAGwoo+7Bepos2uW9y5rDR3uAq cuVNUKRidfXHo7KGWyymlS8pRuqMRjbcDXDi6Pf3E2R84MxWMr2CsBqcvExy97A/1Hgg 3u6WFpHyaUgd03Iyl9PZdCODxKR5M6yCk5C9qczSgXArUQmSlppXu1NO1bpGHdgVLP2u Lwmw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id m3si5896159qkh.262.2017.09.04.05.40.52 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 04 Sep 2017 05:40:53 -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; Authentication-Results: mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:59613 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1doqgM-00078j-Th for patch@linaro.org; Mon, 04 Sep 2017 08:40:50 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52354) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1doqSG-0004sW-Kt for qemu-devel@nongnu.org; Mon, 04 Sep 2017 08:26:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1doqS6-0004gD-8K for qemu-devel@nongnu.org; Mon, 04 Sep 2017 08:26:16 -0400 Received: from orth.archaic.org.uk ([2001:8b0:1d0::2]:37110) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1doqS5-0004ej-W5 for qemu-devel@nongnu.org; Mon, 04 Sep 2017 08:26:06 -0400 Received: from pm215 by orth.archaic.org.uk with local (Exim 4.89) (envelope-from ) id 1doqS5-0005TQ-18 for qemu-devel@nongnu.org; Mon, 04 Sep 2017 13:26:05 +0100 From: Peter Maydell To: qemu-devel@nongnu.org Date: Mon, 4 Sep 2017 13:25:41 +0100 Message-Id: <1504527967-29248-11-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1504527967-29248-1-git-send-email-peter.maydell@linaro.org> References: <1504527967-29248-1-git-send-email-peter.maydell@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2001:8b0:1d0::2 Subject: [Qemu-devel] [PULL 10/36] target/arm: Don't use cpsr_write/cpsr_read to transfer M profile XPSR X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 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" For M profile the XPSR is a similar but not identical format to the A profile CPSR/SPSR. (For instance the Thumb bit is in a different place.) For guest accesses we make the M profile code go through xpsr_read() and xpsr_write() which handle the different layout. However for migration we use cpsr_read() and cpsr_write() to marshal state into and out of the migration data stream. This is pretty confusing and works more by luck than anything else. Make M profile migration use xpsr_read() and xpsr_write() instead. The most complicated part of this is handling the possibility that the migration source is an older QEMU which hands us a CPSR format value; helpfully we can always tell the two apart. Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson Message-id: 1501692241-23310-11-git-send-email-peter.maydell@linaro.org --- target/arm/machine.c | 49 ++++++++++++++++++++++++++++++++++--------------- 1 file changed, 34 insertions(+), 15 deletions(-) -- 2.7.4 diff --git a/target/arm/machine.c b/target/arm/machine.c index 2fb4b762..3193b00 100644 --- a/target/arm/machine.c +++ b/target/arm/machine.c @@ -217,21 +217,37 @@ static int get_cpsr(QEMUFile *f, void *opaque, size_t size, uint32_t val = qemu_get_be32(f); if (arm_feature(env, ARM_FEATURE_M)) { - /* If the I or F bits are set then this is a migration from - * an old QEMU which still stored the M profile FAULTMASK - * and PRIMASK in env->daif. Set v7m.faultmask and v7m.primask - * accordingly, and then clear the bits so they don't confuse - * cpsr_write(). For a new QEMU, the bits here will always be - * clear, and the data is transferred using the - * vmstate_m_faultmask_primask subsection. - */ - if (val & CPSR_F) { - env->v7m.faultmask = 1; - } - if (val & CPSR_I) { - env->v7m.primask = 1; + if (val & XPSR_EXCP) { + /* This is a CPSR format value from an older QEMU. (We can tell + * because values transferred in XPSR format always have zero + * for the EXCP field, and CPSR format will always have bit 4 + * set in CPSR_M.) Rearrange it into XPSR format. The significant + * differences are that the T bit is not in the same place, the + * primask/faultmask info may be in the CPSR I and F bits, and + * we do not want the mode bits. + */ + uint32_t newval = val; + + newval &= (CPSR_NZCV | CPSR_Q | CPSR_IT | CPSR_GE); + if (val & CPSR_T) { + newval |= XPSR_T; + } + /* If the I or F bits are set then this is a migration from + * an old QEMU which still stored the M profile FAULTMASK + * and PRIMASK in env->daif. For a new QEMU, the data is + * transferred using the vmstate_m_faultmask_primask subsection. + */ + if (val & CPSR_F) { + env->v7m.faultmask = 1; + } + if (val & CPSR_I) { + env->v7m.primask = 1; + } + val = newval; } - val &= ~(CPSR_F | CPSR_I); + /* Ignore the low bits, they are handled by vmstate_m. */ + xpsr_write(env, val, ~XPSR_EXCP); + return 0; } env->aarch64 = ((val & PSTATE_nRW) == 0); @@ -252,7 +268,10 @@ static int put_cpsr(QEMUFile *f, void *opaque, size_t size, CPUARMState *env = &cpu->env; uint32_t val; - if (is_a64(env)) { + if (arm_feature(env, ARM_FEATURE_M)) { + /* The low 9 bits are v7m.exception, which is handled by vmstate_m. */ + val = xpsr_read(env) & ~XPSR_EXCP; + } else if (is_a64(env)) { val = pstate_read(env); } else { val = cpsr_read(env); From patchwork Mon Sep 4 12:25:42 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 111560 Delivered-To: patch@linaro.org Received: by 10.140.94.166 with SMTP id g35csp1466177qge; Mon, 4 Sep 2017 05:32:03 -0700 (PDT) X-Google-Smtp-Source: ADKCNb6Js4roTuzBMElIbwEIp6Z2ItoLHvbngjaKola943F6KHWGQTLimc4l0PhcYT8m8W7Fvw8W X-Received: by 10.200.58.165 with SMTP id x34mr294070qte.261.1504528323140; Mon, 04 Sep 2017 05:32:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1504528323; cv=none; d=google.com; s=arc-20160816; b=NcwcnEOpwEkIpSgxpMAsgiwsmwFRbsMMHGSygnF+iiW6lLa7I5UbhwFdE6C/Nll35E BXWzqEH2I1Wj/le73ZRMebFCGlCIEPSv4WpN9GlYSAz8EbHhB4wIz4Bu92QpS8BoJU6i 5RjUc1vOSf/lxnA6Y+tt3EHV8sJrFUAwmfNeKnntrr1Uz6hiYb0CUxKp72jcy30LysGo +8O0zNHgXzwIe57MfWWkptcs3qTX9k0bTjaUiEKEr4qJKxDJARULgDP2MLLZpgtbJubt ZBHmkodLDkXiuCZzCu15mvCihO0TS/4qpjgJdXZd6yWx6/MhUKoJrJVJ2o9wC7VRCyyM FoFg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:arc-authentication-results; bh=ETkFounxx5PIf8YbyyW98PMlGhf2tYvqEt28r/N2oIU=; b=fnfn64XVMtpRdiosfKko8WYSJRJp1RM4vb/2g8PFTdS07gUWjHUMqmJ/BvMLjqnuUK uZBY4OCaqI4hkk/WA9vZfDmuUL01U97aui6wD9736VcbfqtDoBm3FrBPYB2ZeAU/UWFT ezr3eINls2L72t2/2M/QbBhXhqedmyDhXGH8ybM3+P2nrG7e70u9l3ofpM5wJjW93y+l +enFIqbxu7P+MDnWImDUC3+El3MyISGtWT34WlW7i14HESHOyKb4oonhxwDs6wg842Na W6BseW3vcKV89Z7C1TRAEddN4TUsOp4KAvDkplAAN1FIEAP+4Y/BVX1L/ZTnioIo1uww 9CkQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id m65si5538775qkm.547.2017.09.04.05.32.02 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 04 Sep 2017 05:32:03 -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; Authentication-Results: mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:59558 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1doqXp-0000Sh-30 for patch@linaro.org; Mon, 04 Sep 2017 08:32:01 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52383) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1doqSI-0004tp-50 for qemu-devel@nongnu.org; Mon, 04 Sep 2017 08:26:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1doqS7-0004he-4m for qemu-devel@nongnu.org; Mon, 04 Sep 2017 08:26:18 -0400 Received: from orth.archaic.org.uk ([2001:8b0:1d0::2]:37110) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1doqS6-0004ej-Tm for qemu-devel@nongnu.org; Mon, 04 Sep 2017 08:26:07 -0400 Received: from pm215 by orth.archaic.org.uk with local (Exim 4.89) (envelope-from ) id 1doqS5-0005Ts-RL for qemu-devel@nongnu.org; Mon, 04 Sep 2017 13:26:05 +0100 From: Peter Maydell To: qemu-devel@nongnu.org Date: Mon, 4 Sep 2017 13:25:42 +0100 Message-Id: <1504527967-29248-12-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1504527967-29248-1-git-send-email-peter.maydell@linaro.org> References: <1504527967-29248-1-git-send-email-peter.maydell@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2001:8b0:1d0::2 Subject: [Qemu-devel] [PULL 11/36] target/arm: Make arm_cpu_dump_state() handle the M-profile XPSR X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 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" Make the arm_cpu_dump_state() debug logging handle the M-profile XPSR rather than assuming it's an A-profile CPSR. On M profile the PSR line of a register dump will now look like this: XPSR=41000000 -Z-- T priv-thread Signed-off-by: Peter Maydell Reviewed-by: Edgar E. Iglesias Reviewed-by: Richard Henderson Message-id: 1501692241-23310-12-git-send-email-peter.maydell@linaro.org --- target/arm/translate.c | 58 ++++++++++++++++++++++++++++++++++---------------- 1 file changed, 40 insertions(+), 18 deletions(-) -- 2.7.4 diff --git a/target/arm/translate.c b/target/arm/translate.c index 3c14cb0..e52a6d7 100644 --- a/target/arm/translate.c +++ b/target/arm/translate.c @@ -12215,8 +12215,6 @@ void arm_cpu_dump_state(CPUState *cs, FILE *f, fprintf_function cpu_fprintf, ARMCPU *cpu = ARM_CPU(cs); CPUARMState *env = &cpu->env; int i; - uint32_t psr; - const char *ns_status; if (is_a64(env)) { aarch64_cpu_dump_state(cs, f, cpu_fprintf, flags); @@ -12230,24 +12228,48 @@ void arm_cpu_dump_state(CPUState *cs, FILE *f, fprintf_function cpu_fprintf, else cpu_fprintf(f, " "); } - psr = cpsr_read(env); - if (arm_feature(env, ARM_FEATURE_EL3) && - (psr & CPSR_M) != ARM_CPU_MODE_MON) { - ns_status = env->cp15.scr_el3 & SCR_NS ? "NS " : "S "; + if (arm_feature(env, ARM_FEATURE_M)) { + uint32_t xpsr = xpsr_read(env); + const char *mode; + + if (xpsr & XPSR_EXCP) { + mode = "handler"; + } else { + if (env->v7m.control & R_V7M_CONTROL_NPRIV_MASK) { + mode = "unpriv-thread"; + } else { + mode = "priv-thread"; + } + } + + cpu_fprintf(f, "XPSR=%08x %c%c%c%c %c %s\n", + xpsr, + xpsr & XPSR_N ? 'N' : '-', + xpsr & XPSR_Z ? 'Z' : '-', + xpsr & XPSR_C ? 'C' : '-', + xpsr & XPSR_V ? 'V' : '-', + xpsr & XPSR_T ? 'T' : 'A', + mode); } else { - ns_status = ""; - } - - cpu_fprintf(f, "PSR=%08x %c%c%c%c %c %s%s%d\n", - psr, - psr & (1 << 31) ? 'N' : '-', - psr & (1 << 30) ? 'Z' : '-', - psr & (1 << 29) ? 'C' : '-', - psr & (1 << 28) ? 'V' : '-', - psr & CPSR_T ? 'T' : 'A', - ns_status, - cpu_mode_names[psr & 0xf], (psr & 0x10) ? 32 : 26); + uint32_t psr = cpsr_read(env); + const char *ns_status = ""; + + if (arm_feature(env, ARM_FEATURE_EL3) && + (psr & CPSR_M) != ARM_CPU_MODE_MON) { + ns_status = env->cp15.scr_el3 & SCR_NS ? "NS " : "S "; + } + + cpu_fprintf(f, "PSR=%08x %c%c%c%c %c %s%s%d\n", + psr, + psr & CPSR_N ? 'N' : '-', + psr & CPSR_Z ? 'Z' : '-', + psr & CPSR_C ? 'C' : '-', + psr & CPSR_V ? 'V' : '-', + psr & CPSR_T ? 'T' : 'A', + ns_status, + cpu_mode_names[psr & 0xf], (psr & 0x10) ? 32 : 26); + } if (flags & CPU_DUMP_FPU) { int numvfpregs = 0; From patchwork Mon Sep 4 12:25:43 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 111564 Delivered-To: patch@linaro.org Received: by 10.140.94.166 with SMTP id g35csp1469723qge; Mon, 4 Sep 2017 05:35:18 -0700 (PDT) X-Google-Smtp-Source: ADKCNb475pxDCF97xoMmmyzeYmrHA8MP5X6TLRwXtt7K/rQtePkxghFpIfmSGjj5uGDKYjEqbEAy X-Received: by 10.55.169.81 with SMTP id s78mr674659qke.34.1504528518721; Mon, 04 Sep 2017 05:35:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1504528518; cv=none; d=google.com; s=arc-20160816; b=TnqfZQmmuRHnDexFNq3Il/uTh+goCIlNAhc65eejp0e3A3jr+k9Nj352mXQlhTDIa1 TSA6BM7+ZSIwZTswNprYPY3+Q7trKjU/YgJKpZSmyIAX32gXAxYtfJHUArZtVqUWIxQC 1ghwCwWhV+7xN9Vvy1mq6WGJQuyC9rgnrVl/8Dgc7HYUnVWQpt1/t+5HzeJlgH+yQnzc oKXBaUhCVe3YvHhfxOWGURwoj3vr8VgJSP3W58DEbNLHWcphSwF3qU8PuxhmpXPyN8yg n/ozH96UCkM6fw9Bhxchc11eGTQ3cby6z4vEoEAqUSR0iFGfa088r0H77pRAbzg1H1DL 0u2g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:arc-authentication-results; bh=M+Ls+oLVynWK6aN53JXN4hFFeuR179bRPOqwpGl4ydI=; b=zcs2Lui4FYI/tLozh4BbB9PE0IgvHLj4yXbqEBytzrhQfTF8nI4kQwfp6OFymG+40H MNuSe+sRrEVlKqXQVfUrFVyh6Hsp4jCOFWndu54tSmNzopqY+UmpkpMhEDIz3SaerM0H R7uioVasWJ4cphL+Zrbfkn8U+Z13qDGpwn7fY06W3mAvv26YLsiY/OsupZpcRcz7zM9f 5NamobhCd/R5mOTa4NY8U8USKjyPZu9xBXoje5W8+cst/cX07JuolwzafiEr3mTo8E5e FTVWTBrJuPyVAd2+LUVfFheVFbGoA2fXiUB41yIspnYwCp81v4/ZYg6y6Ik+v4DUqsYI Oy2w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id k10si5796244qkk.88.2017.09.04.05.35.18 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 04 Sep 2017 05:35:18 -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; Authentication-Results: mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:59571 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1doqay-0002m1-Jk for patch@linaro.org; Mon, 04 Sep 2017 08:35:16 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52439) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1doqSK-0004uN-93 for qemu-devel@nongnu.org; Mon, 04 Sep 2017 08:26:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1doqS9-0004jD-1N for qemu-devel@nongnu.org; Mon, 04 Sep 2017 08:26:20 -0400 Received: from orth.archaic.org.uk ([2001:8b0:1d0::2]:37112) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1doqS8-0004ia-QO for qemu-devel@nongnu.org; Mon, 04 Sep 2017 08:26:08 -0400 Received: from pm215 by orth.archaic.org.uk with local (Exim 4.89) (envelope-from ) id 1doqS7-0005UZ-RO for qemu-devel@nongnu.org; Mon, 04 Sep 2017 13:26:07 +0100 From: Peter Maydell To: qemu-devel@nongnu.org Date: Mon, 4 Sep 2017 13:25:43 +0100 Message-Id: <1504527967-29248-13-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1504527967-29248-1-git-send-email-peter.maydell@linaro.org> References: <1504527967-29248-1-git-send-email-peter.maydell@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2001:8b0:1d0::2 Subject: [Qemu-devel] [PULL 12/36] target/arm: Don't calculate lr in arm_v7m_cpu_do_interrupt() until needed X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 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" Move the code in arm_v7m_cpu_do_interrupt() that calculates the magic LR value down to when we're actually going to use it. Having the calculation and use so far apart makes the code a little harder to understand than it needs to be. Signed-off-by: Peter Maydell Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Edgar E. Iglesias Reviewed-by: Richard Henderson Message-id: 1501692241-23310-13-git-send-email-peter.maydell@linaro.org --- target/arm/helper.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) -- 2.7.4 diff --git a/target/arm/helper.c b/target/arm/helper.c index 9410856..267a170 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -6306,13 +6306,6 @@ void arm_v7m_cpu_do_interrupt(CPUState *cs) arm_log_exception(cs->exception_index); - lr = 0xfffffff1; - if (env->v7m.control & R_V7M_CONTROL_SPSEL_MASK) { - lr |= 4; - } - if (env->v7m.exception == 0) - lr |= 8; - /* For exceptions we just mark as pending on the NVIC, and let that handle it. */ switch (cs->exception_index) { @@ -6403,6 +6396,14 @@ void arm_v7m_cpu_do_interrupt(CPUState *cs) return; /* Never happens. Keep compiler happy. */ } + lr = 0xfffffff1; + if (env->v7m.control & R_V7M_CONTROL_SPSEL_MASK) { + lr |= 4; + } + if (env->v7m.exception == 0) { + lr |= 8; + } + v7m_push_stack(cpu); v7m_exception_taken(cpu, lr); qemu_log_mask(CPU_LOG_INT, "... as %d\n", env->v7m.exception); From patchwork Mon Sep 4 12:25:44 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 111567 Delivered-To: patch@linaro.org Received: by 10.140.94.166 with SMTP id g35csp1473177qge; Mon, 4 Sep 2017 05:38:32 -0700 (PDT) X-Google-Smtp-Source: ADKCNb6L4u6EiCD6fm4uoZW24jPLi+ArxNa4UGrCD8kMqt1BEATDOuQlqDC2L/hgfx4KzI+8prLh X-Received: by 10.200.44.123 with SMTP id e56mr433880qta.308.1504528712031; Mon, 04 Sep 2017 05:38:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1504528712; cv=none; d=google.com; s=arc-20160816; b=L/y7JNqoZvq1RA8sgE4BStnsuKO8OxzN00biJxBpyUf1mdWGY0F2GoDDKeNsLTkN03 wzn4XKxRK6HmNkYu9yyYjj/DAxuUHTY+BHfh9/9KvE8wHcAl7K8YuIDT8FV0ShzFOxhZ 3+bMJrr6ZXs1ffG9r8O5y+H1x6B6g+vAvAsRiRBmO2s32ykKL3SRjhSHZ68Um6LVe98v QsbtWXDZ6gVMjj0OXrJnyj3jLL4wxA8giBpAyTftZxbMY043cXTpT6dOs57ksPnrg6jZ sy4rTgc0Qqay46GZwY19b+tFW/4OYgoeEAxtSjCy0aeBBZvxLRlGO+FQzN0MLW3Na1Zv lYwA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:arc-authentication-results; bh=UDdlcQ+XDg7JO2193u7x86Fzw70AP2D0Ia1NnVUMUfU=; b=M4EJexaX7YED4dnrYLbD2ql9rIBxGlWLsiWqGceoPqeHzQEsCgLVZp6VVxka1604Nc qrsrDTbwtGQk5I3o8FvWDXS3rsy4/8AELIF4Lk6A2YnT68JarzHeqW25p0lwNevjhobZ fK1JgJFtMzl6wLAUvAV0nj/8rCkmxi+9CzsvKrsbw2Fy9Xu02szog3M/ImEOZY909srn dLxP5fDArD1nYeMt4Z7MBgtasQ6smwieS351F7Ik8KEASDtACwozQvSuRXibDSmhbbs4 tLgTPqNfRD14DwqTH/yZQcQEf8NTnXTXa2YHIoTaGhwZNmfqPyTv/+zU77zTzLVVqeaF DP6A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id o64si5394039qkd.65.2017.09.04.05.38.31 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 04 Sep 2017 05:38:32 -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; Authentication-Results: mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:59599 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1doqe5-0005My-VT for patch@linaro.org; Mon, 04 Sep 2017 08:38:30 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52487) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1doqSN-0004xq-GD for qemu-devel@nongnu.org; Mon, 04 Sep 2017 08:26:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1doqSA-0004kU-Li for qemu-devel@nongnu.org; Mon, 04 Sep 2017 08:26:23 -0400 Received: from orth.archaic.org.uk ([2001:8b0:1d0::2]:37114) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1doqSA-0004k3-Ex for qemu-devel@nongnu.org; Mon, 04 Sep 2017 08:26:10 -0400 Received: from pm215 by orth.archaic.org.uk with local (Exim 4.89) (envelope-from ) id 1doqS9-0005V0-GH for qemu-devel@nongnu.org; Mon, 04 Sep 2017 13:26:09 +0100 From: Peter Maydell To: qemu-devel@nongnu.org Date: Mon, 4 Sep 2017 13:25:44 +0100 Message-Id: <1504527967-29248-14-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1504527967-29248-1-git-send-email-peter.maydell@linaro.org> References: <1504527967-29248-1-git-send-email-peter.maydell@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2001:8b0:1d0::2 Subject: [Qemu-devel] [PULL 13/36] target/arm: Create and use new function arm_v7m_is_handler_mode() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 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" Add a utility function for testing whether the CPU is in Handler mode; this is just a check whether v7m.exception is non-zero, but we do it in several places and it makes the code a bit easier to read to not have to mentally figure out what the test is testing. Signed-off-by: Peter Maydell Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Edgar E. Iglesias Reviewed-by: Richard Henderson Message-id: 1501692241-23310-14-git-send-email-peter.maydell@linaro.org --- target/arm/cpu.h | 10 ++++++++-- target/arm/helper.c | 8 ++++---- 2 files changed, 12 insertions(+), 6 deletions(-) -- 2.7.4 diff --git a/target/arm/cpu.h b/target/arm/cpu.h index 8ef552a..eabef00 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -1629,13 +1629,19 @@ static inline int arm_highest_el(CPUARMState *env) return 1; } +/* Return true if a v7M CPU is in Handler mode */ +static inline bool arm_v7m_is_handler_mode(CPUARMState *env) +{ + return env->v7m.exception != 0; +} + /* Return the current Exception Level (as per ARMv8; note that this differs * from the ARMv7 Privilege Level). */ static inline int arm_current_el(CPUARMState *env) { if (arm_feature(env, ARM_FEATURE_M)) { - return !((env->v7m.exception == 0) && (env->v7m.control & 1)); + return arm_v7m_is_handler_mode(env) || !(env->v7m.control & 1); } if (is_a64(env)) { @@ -2635,7 +2641,7 @@ static inline void cpu_get_tb_cpu_state(CPUARMState *env, target_ulong *pc, } *flags |= fp_exception_el(env) << ARM_TBFLAG_FPEXC_EL_SHIFT; - if (env->v7m.exception != 0) { + if (arm_v7m_is_handler_mode(env)) { *flags |= ARM_TBFLAG_HANDLER_MASK; } diff --git a/target/arm/helper.c b/target/arm/helper.c index 267a170..37e7fd9 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -6142,7 +6142,7 @@ static void do_v7m_exception_exit(ARMCPU *cpu) * that jumps to magic addresses don't have magic behaviour unless * we're in Handler mode (compare pseudocode BXWritePC()). */ - assert(env->v7m.exception != 0); + assert(arm_v7m_is_handler_mode(env)); /* In the spec pseudocode ExceptionReturn() is called directly * from BXWritePC() and gets the full target PC value including @@ -6249,7 +6249,7 @@ static void do_v7m_exception_exit(ARMCPU *cpu) * resuming in Thread mode. If that doesn't match what the * exception return type specified then this is a UsageFault. */ - if (return_to_handler == (env->v7m.exception == 0)) { + if (return_to_handler != arm_v7m_is_handler_mode(env)) { /* Take an INVPC UsageFault by pushing the stack again. */ armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_USAGE); env->v7m.cfsr |= R_V7M_CFSR_INVPC_MASK; @@ -6400,7 +6400,7 @@ void arm_v7m_cpu_do_interrupt(CPUState *cs) if (env->v7m.control & R_V7M_CONTROL_SPSEL_MASK) { lr |= 4; } - if (env->v7m.exception == 0) { + if (!arm_v7m_is_handler_mode(env)) { lr |= 8; } @@ -8793,7 +8793,7 @@ void HELPER(v7m_msr)(CPUARMState *env, uint32_t maskreg, uint32_t val) * switch_v7m_sp() deals with updating the SPSEL bit in * env->v7m.control, so we only need update the others. */ - if (env->v7m.exception == 0) { + if (!arm_v7m_is_handler_mode(env)) { switch_v7m_sp(env, (val & R_V7M_CONTROL_SPSEL_MASK) != 0); } env->v7m.control &= ~R_V7M_CONTROL_NPRIV_MASK; From patchwork Mon Sep 4 12:25:45 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 111566 Delivered-To: patch@linaro.org Received: by 10.140.94.166 with SMTP id g35csp1472827qge; Mon, 4 Sep 2017 05:38:14 -0700 (PDT) X-Google-Smtp-Source: ADKCNb5qLXhGD7e+1G/yIJzvQNSGIuCZMhQ9gpgS14WJ1AB7bP1cRxEWCh1qMJ36mUpc6flA3kK0 X-Received: by 10.200.2.146 with SMTP id p18mr405904qtg.326.1504528694117; Mon, 04 Sep 2017 05:38:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1504528694; cv=none; d=google.com; s=arc-20160816; b=OoD1OE0OHRBtk9/3C15eKlUJGnHGF7rnSKi9GieJudBN3KCYPtbES/es1FCMjPATT2 7W5O6MGmtsly4HOOCBCU7YoKEKG0aPmdJUYwQ0+5xfRp+44iBZzoZyytVfj4UesTYctY D5Tf/56A/NoPQCILLgF55W5Lm0/hC6XuZPrdpWuJIlGMaC9P+R3aGsI2MPUlq4ua2mG+ ASrcdqLy65zJ4BP52OlMkVT/POREi9GsRhzfLwDWP0IVLuE7EZoLZ/hbm+LZipg82CpW dHe366n1ihfpeUq8yc1p/bIz+VGOQsn3rDBMvzXn7WZ+frXgn1Q3z7NntYS5bKVYA5s3 ZhPw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:arc-authentication-results; bh=mTxT8gjLU5xdqGQ/jMvFsBZrlP1I+6/Vv72eLY12FDQ=; b=ueYhxYzsYETyN9mc8lUyX93yKJ9p3oHH2Wwju9p+CRaINxfRR4Y3oF+WzU/6jM7kNG OoXnDPo47shW4PE2669cEWVZWXoRze7/3ack+9nLlcriaBVxRigvvrva/9FlniRXOSlm lruXW9Muh36/+nYp38stGiIGYacEx9/HkiiQzDYsHZ51YJGrOtIK/wRXtSVRx10P4QuJ v4qcMJy1AIgCN7Ox0mhKaWG+/45h0w53RRfnxLJLVdmm7rRSWljg2U7KJTztYrEsHriG yqsNlEXOxQst8TRiGdtdcMv1x8WpLfXnGcbDRPld++xyhmpzQ8CwwcvXQGGksjbkiSVM YVDQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id t81si5479113qka.138.2017.09.04.05.38.13 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 04 Sep 2017 05:38:14 -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; Authentication-Results: mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:59597 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1doqdo-0005Ca-1d for patch@linaro.org; Mon, 04 Sep 2017 08:38:12 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52567) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1doqSQ-000511-Kq for qemu-devel@nongnu.org; Mon, 04 Sep 2017 08:26:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1doqSB-0004ls-VV for qemu-devel@nongnu.org; Mon, 04 Sep 2017 08:26:26 -0400 Received: from orth.archaic.org.uk ([2001:8b0:1d0::2]:37116) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1doqSB-0004l7-OY for qemu-devel@nongnu.org; Mon, 04 Sep 2017 08:26:11 -0400 Received: from pm215 by orth.archaic.org.uk with local (Exim 4.89) (envelope-from ) id 1doqSA-0005VE-Ph for qemu-devel@nongnu.org; Mon, 04 Sep 2017 13:26:10 +0100 From: Peter Maydell To: qemu-devel@nongnu.org Date: Mon, 4 Sep 2017 13:25:45 +0100 Message-Id: <1504527967-29248-15-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1504527967-29248-1-git-send-email-peter.maydell@linaro.org> References: <1504527967-29248-1-git-send-email-peter.maydell@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2001:8b0:1d0::2 Subject: [Qemu-devel] [PULL 14/36] armv7m_nvic.h: Move from include/hw/arm to include/hw/intc X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 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" The armv7m_nvic.h header file was accidentally placed in include/hw/arm; move it to include/hw/intc to match where its corresponding .c file lives. Signed-off-by: Peter Maydell Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Edgar E. Iglesias Reviewed-by: Richard Henderson Message-id: 1501692241-23310-15-git-send-email-peter.maydell@linaro.org --- include/hw/arm/armv7m.h | 2 +- include/hw/{arm => intc}/armv7m_nvic.h | 0 hw/intc/armv7m_nvic.c | 2 +- 3 files changed, 2 insertions(+), 2 deletions(-) rename include/hw/{arm => intc}/armv7m_nvic.h (100%) -- 2.7.4 diff --git a/include/hw/arm/armv7m.h b/include/hw/arm/armv7m.h index a9b3f2a..10eb058 100644 --- a/include/hw/arm/armv7m.h +++ b/include/hw/arm/armv7m.h @@ -11,7 +11,7 @@ #define HW_ARM_ARMV7M_H #include "hw/sysbus.h" -#include "hw/arm/armv7m_nvic.h" +#include "hw/intc/armv7m_nvic.h" #define TYPE_BITBAND "ARM,bitband-memory" #define BITBAND(obj) OBJECT_CHECK(BitBandState, (obj), TYPE_BITBAND) diff --git a/include/hw/arm/armv7m_nvic.h b/include/hw/intc/armv7m_nvic.h similarity index 100% rename from include/hw/arm/armv7m_nvic.h rename to include/hw/intc/armv7m_nvic.h diff --git a/hw/intc/armv7m_nvic.c b/hw/intc/armv7m_nvic.c index 343bc16..5a18025 100644 --- a/hw/intc/armv7m_nvic.c +++ b/hw/intc/armv7m_nvic.c @@ -17,7 +17,7 @@ #include "hw/sysbus.h" #include "qemu/timer.h" #include "hw/arm/arm.h" -#include "hw/arm/armv7m_nvic.h" +#include "hw/intc/armv7m_nvic.h" #include "target/arm/cpu.h" #include "exec/exec-all.h" #include "qemu/log.h" From patchwork Mon Sep 4 12:25:46 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 111568 Delivered-To: patch@linaro.org Received: by 10.140.94.166 with SMTP id g35csp1473564qge; Mon, 4 Sep 2017 05:38:51 -0700 (PDT) X-Google-Smtp-Source: ADKCNb5lmehNZLf90fZBBwAHubksNRkUoQD6fKH2k/ay+mlXulmKtLyzaiqbeh2sToSMt2zz75Qf X-Received: by 10.55.76.196 with SMTP id z187mr644542qka.100.1504528731583; Mon, 04 Sep 2017 05:38:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1504528731; cv=none; d=google.com; s=arc-20160816; b=HjTetU01tVokOq17fKgjV1EWRq14UaGdlfEVsXRek2PrwipFLiBPErUW3ew5u3rLa0 9fo3dhcfFIncGyU/fZ+IYBvNJBUwLsLdLdhxHeOWKN8fNs0xLOJRiOuP4UT+AabbIXs3 QtlNamAAIBbkbY2zvRl2gruWFSkNlKKPPP52FlA46LvBql95EFS0N9USZPfiPWLv2beZ WYbHke1VT6KlZiWwus+YFV2D9cdKY+s4YC772dgaofT6Y8vZLc4NGQJhIIsW5t4xeStk If0gpCMQo2c/m7dYnHqcEOhhUYJdCqqWabo9/AtxGWI+bHyNh6Jl7CL5Cb/jIVotiOIA 2L5g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:arc-authentication-results; bh=mthgaQ+JY23MjmRqUJ0M99xsHBiE93FZ/2mAlcO9AY8=; b=OQXaodHq8oUugPJmsNkXbRCsfkmR53Un4cGDO3QzD8EGwJdKhPDulG09yegOvo2yLA 5wib+9pSSKDyUwcPNvlwPV06lsS1DYAyAAK3BUWUejysAN+r47qiCUDee6aGrczgGz1L LbsYdAWWR5FvgoVem+tk/JhLS1ap0dS/c9P6Vg9jjJ4ZZ8DdLqbfcmczXaOOIi8PSRQ+ hAwNQDexjWcxEke0xS/4juxgsxbLwSXsYS3+DFzf519EK2jO+nwl1ctaHUA0BMJBIu7k pMiCw9VZEMzWQa96hgFnqibosGf7yW3xybhvPjwaISNZRJ2Swzn2/0l3qgLNWgNjUA5t qFqA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id l1si6814391qtc.505.2017.09.04.05.38.51 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 04 Sep 2017 05:38:51 -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; Authentication-Results: mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:59604 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1doqeP-0005uT-BG for patch@linaro.org; Mon, 04 Sep 2017 08:38:49 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52588) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1doqSS-00051a-GD for qemu-devel@nongnu.org; Mon, 04 Sep 2017 08:26:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1doqSC-0004mW-UZ for qemu-devel@nongnu.org; Mon, 04 Sep 2017 08:26:28 -0400 Received: from orth.archaic.org.uk ([2001:8b0:1d0::2]:37116) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1doqSC-0004l7-MS for qemu-devel@nongnu.org; Mon, 04 Sep 2017 08:26:12 -0400 Received: from pm215 by orth.archaic.org.uk with local (Exim 4.89) (envelope-from ) id 1doqSB-0005Ve-Hx for qemu-devel@nongnu.org; Mon, 04 Sep 2017 13:26:11 +0100 From: Peter Maydell To: qemu-devel@nongnu.org Date: Mon, 4 Sep 2017 13:25:46 +0100 Message-Id: <1504527967-29248-16-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1504527967-29248-1-git-send-email-peter.maydell@linaro.org> References: <1504527967-29248-1-git-send-email-peter.maydell@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2001:8b0:1d0::2 Subject: [Qemu-devel] [PULL 15/36] nvic: Implement "user accesses BusFault" SCS region behaviour X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 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" The ARMv7M architecture specifies that most of the addresses in the PPB region (which includes the NVIC, systick and system registers) are not accessible to unprivileged accesses, which should BusFault with a few exceptions: * the STIR is configurably user-accessible * the ITM (which we don't implement at all) is always user-accessible Implement this by switching the register access functions to the _with_attrs scheme that lets us distinguish user mode accesses. This allows us to pull the handling of the CCR.USERSETMPEND flag up to the level where we can make it generate a BusFault as it should for non-permitted accesses. Note that until the core ARM CPU code implements turning MEMTX_ERROR into a BusFault the registers will continue to act as RAZ/WI to user accesses. Signed-off-by: Peter Maydell Reviewed-by: Edgar E. Iglesias Reviewed-by: Richard Henderson Message-id: 1501692241-23310-16-git-send-email-peter.maydell@linaro.org --- hw/intc/armv7m_nvic.c | 58 ++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 41 insertions(+), 17 deletions(-) -- 2.7.4 diff --git a/hw/intc/armv7m_nvic.c b/hw/intc/armv7m_nvic.c index 5a18025..bbfe2d5 100644 --- a/hw/intc/armv7m_nvic.c +++ b/hw/intc/armv7m_nvic.c @@ -733,11 +733,8 @@ static void nvic_writel(NVICState *s, uint32_t offset, uint32_t value) } case 0xf00: /* Software Triggered Interrupt Register */ { - /* user mode can only write to STIR if CCR.USERSETMPEND permits it */ int excnum = (value & 0x1ff) + NVIC_FIRST_IRQ; - if (excnum < s->num_irq && - (arm_current_el(&cpu->env) || - (cpu->env.v7m.ccr & R_V7M_CCR_USERSETMPEND_MASK))) { + if (excnum < s->num_irq) { armv7m_nvic_set_pending(s, excnum); } break; @@ -748,14 +745,32 @@ static void nvic_writel(NVICState *s, uint32_t offset, uint32_t value) } } -static uint64_t nvic_sysreg_read(void *opaque, hwaddr addr, - unsigned size) +static bool nvic_user_access_ok(NVICState *s, hwaddr offset) +{ + /* Return true if unprivileged access to this register is permitted. */ + switch (offset) { + case 0xf00: /* STIR: accessible only if CCR.USERSETMPEND permits */ + return s->cpu->env.v7m.ccr & R_V7M_CCR_USERSETMPEND_MASK; + default: + /* All other user accesses cause a BusFault unconditionally */ + return false; + } +} + +static MemTxResult nvic_sysreg_read(void *opaque, hwaddr addr, + uint64_t *data, unsigned size, + MemTxAttrs attrs) { NVICState *s = (NVICState *)opaque; uint32_t offset = addr; unsigned i, startvec, end; uint32_t val; + if (attrs.user && !nvic_user_access_ok(s, addr)) { + /* Generate BusFault for unprivileged accesses */ + return MEMTX_ERROR; + } + switch (offset) { /* reads of set and clear both return the status */ case 0x100 ... 0x13f: /* NVIC Set enable */ @@ -826,11 +841,13 @@ static uint64_t nvic_sysreg_read(void *opaque, hwaddr addr, } trace_nvic_sysreg_read(addr, val, size); - return val; + *data = val; + return MEMTX_OK; } -static void nvic_sysreg_write(void *opaque, hwaddr addr, - uint64_t value, unsigned size) +static MemTxResult nvic_sysreg_write(void *opaque, hwaddr addr, + uint64_t value, unsigned size, + MemTxAttrs attrs) { NVICState *s = (NVICState *)opaque; uint32_t offset = addr; @@ -839,6 +856,11 @@ static void nvic_sysreg_write(void *opaque, hwaddr addr, trace_nvic_sysreg_write(addr, value, size); + if (attrs.user && !nvic_user_access_ok(s, addr)) { + /* Generate BusFault for unprivileged accesses */ + return MEMTX_ERROR; + } + switch (offset) { case 0x100 ... 0x13f: /* NVIC Set enable */ offset += 0x80; @@ -853,7 +875,7 @@ static void nvic_sysreg_write(void *opaque, hwaddr addr, } } nvic_irq_update(s); - return; + return MEMTX_OK; case 0x200 ... 0x23f: /* NVIC Set pend */ /* the special logic in armv7m_nvic_set_pending() * is not needed since IRQs are never escalated @@ -870,9 +892,9 @@ static void nvic_sysreg_write(void *opaque, hwaddr addr, } } nvic_irq_update(s); - return; + return MEMTX_OK; case 0x300 ... 0x33f: /* NVIC Active */ - return; /* R/O */ + return MEMTX_OK; /* R/O */ case 0x400 ... 0x5ef: /* NVIC Priority */ startvec = 8 * (offset - 0x400) + NVIC_FIRST_IRQ; /* vector # */ @@ -880,26 +902,28 @@ static void nvic_sysreg_write(void *opaque, hwaddr addr, set_prio(s, startvec + i, (value >> (i * 8)) & 0xff); } nvic_irq_update(s); - return; + return MEMTX_OK; case 0xd18 ... 0xd23: /* System Handler Priority. */ for (i = 0; i < size; i++) { unsigned hdlidx = (offset - 0xd14) + i; set_prio(s, hdlidx, (value >> (i * 8)) & 0xff); } nvic_irq_update(s); - return; + return MEMTX_OK; } if (size == 4) { nvic_writel(s, offset, value); - return; + return MEMTX_OK; } qemu_log_mask(LOG_GUEST_ERROR, "NVIC: Bad write of size %d at offset 0x%x\n", size, offset); + /* This is UNPREDICTABLE; treat as RAZ/WI */ + return MEMTX_OK; } static const MemoryRegionOps nvic_sysreg_ops = { - .read = nvic_sysreg_read, - .write = nvic_sysreg_write, + .read_with_attrs = nvic_sysreg_read, + .write_with_attrs = nvic_sysreg_write, .endianness = DEVICE_NATIVE_ENDIAN, }; From patchwork Mon Sep 4 12:25:47 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 111569 Delivered-To: patch@linaro.org Received: by 10.140.94.166 with SMTP id g35csp1474254qge; Mon, 4 Sep 2017 05:39:26 -0700 (PDT) X-Google-Smtp-Source: ADKCNb5Lz1HXCskPcpOSi1mBjcbUpWgF28ZmDaZzSfyduGFdnonVE4UdJ9QBclchE4pMJLe1X9iX X-Received: by 10.55.164.87 with SMTP id n84mr539543qke.85.1504528766786; Mon, 04 Sep 2017 05:39:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1504528766; cv=none; d=google.com; s=arc-20160816; b=VdIXdlvx116GmliNKdLQ8lHH4gz4ns59HjWWNrP4Rd20mdaYEPt114yQYEHzLpLLdD O6yzfI757oj2RChpPA3jUyBbyXtAq5P1HZjOe7iYx6asU9aCg5mWBbPWr/iJicBh+2Oz ZG2nwObM8ouy/6g2LQ2alrSWleJaSxajf++hgroUc56kPOpw7NpblN938fYRTYCvkkzs ZkoexhVmzR2/yPVTJwau1Uwh9u7qLZZJw+txtCH/qojXnyMeHsuELLNUpo88D5wErVp2 T/ZOGHsmSRLdvrIHzcyQXBoGWPKrFDrHKRp1xfbQ6lsReWRCYWufYyGpbjlrJ82VtUV8 w1fw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:arc-authentication-results; bh=sm0hyEz0XA049PV2i9sXXuUD6tZfnhcPjtE41tyFzF4=; b=tku0jr7+x34LRJkzDeTrJ6b591yk3UPpql3tKwk31zQfch4hO/jUFMYQQ2igGvnmy1 b1CR/imftnlNpgSy22+/0B/YSD+gjMFuKHBXJ6VzDDLenr5/VwIsblUgZWl91ESgxvqX u4Ksebrv4UnU+J9TsnT3bj9qDL7JQnr/f18bCZgFUt9MRnDFccJJSGSySiPKmcbeigWE tP7J0waK2D74tze+fv6tp9NerU8UIWigflfuREPl+uETFczxA8YrHV9msp6gAuPSMAbk qmNwmT+jNPwxt6bJpQdLkjgH3sfCxf/4rYmMGExqyZTr4s7JiNWujSBiM42h8XmiH9w7 228w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id z11si7062646qta.90.2017.09.04.05.39.26 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 04 Sep 2017 05:39:26 -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; Authentication-Results: mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:59607 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1doqey-0006JR-Lj for patch@linaro.org; Mon, 04 Sep 2017 08:39:24 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52602) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1doqST-00051b-1j for qemu-devel@nongnu.org; Mon, 04 Sep 2017 08:26:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1doqSD-0004n2-Rs for qemu-devel@nongnu.org; Mon, 04 Sep 2017 08:26:29 -0400 Received: from orth.archaic.org.uk ([2001:8b0:1d0::2]:37118) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1doqSD-0004ma-KI for qemu-devel@nongnu.org; Mon, 04 Sep 2017 08:26:13 -0400 Received: from pm215 by orth.archaic.org.uk with local (Exim 4.89) (envelope-from ) id 1doqSC-0005W7-Lg for qemu-devel@nongnu.org; Mon, 04 Sep 2017 13:26:12 +0100 From: Peter Maydell To: qemu-devel@nongnu.org Date: Mon, 4 Sep 2017 13:25:47 +0100 Message-Id: <1504527967-29248-17-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1504527967-29248-1-git-send-email-peter.maydell@linaro.org> References: <1504527967-29248-1-git-send-email-peter.maydell@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2001:8b0:1d0::2 Subject: [Qemu-devel] [PULL 16/36] loader: Handle ELF files with overlapping zero-initialized data X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 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" For embedded systems, notably ARM, one common use of ELF file segments is that the 'physical addresses' represent load addresses and the 'virtual addresses' execution addresses, such that the load addresses are packed into ROM or flash, and the relocation and zero-initialization of data is done at runtime. This means that the 'memsz' in the segment header represents the runtime size of the segment, but the size that needs to be loaded is only the 'filesz'. In particular, paddr+memsz may overlap with the next segment to be loaded, as in this example: 0x70000001 off 0x00007f68 vaddr 0x00008150 paddr 0x00008150 align 2**2 filesz 0x00000008 memsz 0x00000008 flags r-- LOAD off 0x000000f4 vaddr 0x00000000 paddr 0x00000000 align 2**2 filesz 0x00000124 memsz 0x00000124 flags r-- LOAD off 0x00000218 vaddr 0x00000400 paddr 0x00000400 align 2**3 filesz 0x00007d58 memsz 0x00007d58 flags r-x LOAD off 0x00007f70 vaddr 0x20000140 paddr 0x00008158 align 2**3 filesz 0x00000a80 memsz 0x000022f8 flags rw- LOAD off 0x000089f0 vaddr 0x20002438 paddr 0x00008bd8 align 2**0 filesz 0x00000000 memsz 0x00004000 flags rw- LOAD off 0x000089f0 vaddr 0x20000000 paddr 0x20000000 align 2**0 filesz 0x00000000 memsz 0x00000140 flags rw- where the segment at paddr 0x8158 has a memsz of 0x2258 and would overlap with the segment at paddr 0x8bd8 if QEMU's loader tried to honour it. (At runtime the segments will not overlap since their vaddrs are more widely spaced than their paddrs.) Currently if you try to load an ELF file like this with QEMU then it will fail with an error "rom: requested regions overlap", because we create a ROM image for each segment using the memsz as the size. Support ELF files using this scheme, by truncating the zero-initialized part of the segment if it would overlap another segment. This will retain the existing loader behaviour for all ELF files we currently accept, and also accept ELF files which only need 'filesz' bytes to be loaded. Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson Message-id: 1502116754-18867-2-git-send-email-peter.maydell@linaro.org --- include/hw/elf_ops.h | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) -- 2.7.4 diff --git a/include/hw/elf_ops.h b/include/hw/elf_ops.h index a172a60..2e526d3 100644 --- a/include/hw/elf_ops.h +++ b/include/hw/elf_ops.h @@ -362,6 +362,54 @@ static int glue(load_elf, SZ)(const char *name, int fd, goto fail; } } + + /* The ELF spec is somewhat vague about the purpose of the + * physical address field. One common use in the embedded world + * is that physical address field specifies the load address + * and the virtual address field specifies the execution address. + * Segments are packed into ROM or flash, and the relocation + * and zero-initialization of data is done at runtime. This + * means that the memsz header represents the runtime size of the + * segment, but the filesz represents the loadtime size. If + * we try to honour the memsz value for an ELF file like this + * we will end up with overlapping segments (which the + * loader.c code will later reject). + * We support ELF files using this scheme by by checking whether + * paddr + memsz for this segment would overlap with any other + * segment. If so, then we assume it's using this scheme and + * truncate the loaded segment to the filesz size. + * If the segment considered as being memsz size doesn't overlap + * then we use memsz for the segment length, to handle ELF files + * which assume that the loader will do the zero-initialization. + */ + if (mem_size > file_size) { + /* If this segment's zero-init portion overlaps another + * segment's data or zero-init portion, then truncate this one. + * Invalid ELF files where the segments overlap even when + * only file_size bytes are loaded will be rejected by + * the ROM overlap check in loader.c, so we don't try to + * explicitly detect those here. + */ + int j; + elf_word zero_start = ph->p_paddr + file_size; + elf_word zero_end = ph->p_paddr + mem_size; + + for (j = 0; j < ehdr.e_phnum; j++) { + struct elf_phdr *jph = &phdr[j]; + + if (i != j && jph->p_type == PT_LOAD) { + elf_word other_start = jph->p_paddr; + elf_word other_end = jph->p_paddr + jph->p_memsz; + + if (!(other_start >= zero_end || + zero_start >= other_end)) { + mem_size = file_size; + break; + } + } + } + } + /* address_offset is hack for kernel images that are linked at the wrong physical address. */ if (translate_fn) { From patchwork Mon Sep 4 12:25:48 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 111571 Delivered-To: patch@linaro.org Received: by 10.140.94.166 with SMTP id g35csp1477239qge; Mon, 4 Sep 2017 05:42:09 -0700 (PDT) X-Google-Smtp-Source: ADKCNb58siJO03n5pJsmmMrVx4LQn0PdKQJLUjjnEWg0aTK3mcrd9xR+aCvByhJcd3dFrGiASzad X-Received: by 10.55.75.75 with SMTP id y72mr606877qka.118.1504528929840; Mon, 04 Sep 2017 05:42:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1504528929; cv=none; d=google.com; s=arc-20160816; b=VcJ1B0RpMHtg8+4qsLu797Cfsb9O0yKheGUuAuRGS0bJZHNhMmOKzpOXF++b0SzG4o c36AnSogeZnwRU+eH7rb/rRCfe9BVCmxFEYazGq7vMWlQ1z8KZCW5xQ/D6r2Q59NHhvX cYJMa3EXJ4/TWwdIF7qIEw9iQs6TrB1KuGe4WPf+VOI3rcqIC19556mkcsVw+LN1xbmb RMwkiMbWCss9rk0sWqKqfrQJ0uilGLXfI1KQ8HOpgnAMRCay1tzQus70GUSCuYtdnO98 ohhOd9RWyrsbh6ruNA02J/L7c2w2/YNbQd2OVvB7Mvlu+EAQvxxPN1vyEgHA+LbMBhRg /Nfw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:arc-authentication-results; bh=knwPncAkJsiwCSqmuXJFzzfw+xYK89EBGGw+Btd0h58=; b=UVOaNRwnVVxm+sUNR64QUMpTq+v/yS4hB/uAIRZ0oTLJfuF0DXdX+rGCWo+NpkE8qn /amQ9B73OS69iJkbo0XppHFQqFQW6KQWTMGqcSXuwg1IxHRIfXzCuV6RnpxT1KVh1EMl 9C5UyRLVoQB50gApFgePSyCu9HkXYXv+vFRCAc1XSCGwJaKwE7Ln16TQNJVoZ8HmuhOk wHYF0TgeN37GmaEN+FwMNG7PgqRALJ2SzZO12z89MJ3OhpIFbaUNVtTg+seNVgHsmIpi oiIcv4R9oua7ID0rlcbY6FuV/Jwzxp40UsDC1w/fs8xZ67l9CAoJzOJ86RioHiHJvSAZ vm3Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id t8si5569511qki.28.2017.09.04.05.42.09 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 04 Sep 2017 05:42:09 -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; Authentication-Results: mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:59622 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1doqhb-0008Mb-NW for patch@linaro.org; Mon, 04 Sep 2017 08:42:07 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52604) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1doqST-00051d-3g for qemu-devel@nongnu.org; Mon, 04 Sep 2017 08:26:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1doqSF-0004nw-AS for qemu-devel@nongnu.org; Mon, 04 Sep 2017 08:26:29 -0400 Received: from orth.archaic.org.uk ([2001:8b0:1d0::2]:37120) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1doqSF-0004nZ-3a for qemu-devel@nongnu.org; Mon, 04 Sep 2017 08:26:15 -0400 Received: from pm215 by orth.archaic.org.uk with local (Exim 4.89) (envelope-from ) id 1doqSE-0005Wj-4U for qemu-devel@nongnu.org; Mon, 04 Sep 2017 13:26:14 +0100 From: Peter Maydell To: qemu-devel@nongnu.org Date: Mon, 4 Sep 2017 13:25:48 +0100 Message-Id: <1504527967-29248-18-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1504527967-29248-1-git-send-email-peter.maydell@linaro.org> References: <1504527967-29248-1-git-send-email-peter.maydell@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2001:8b0:1d0::2 Subject: [Qemu-devel] [PULL 17/36] loader: Ignore zero-sized ELF segments X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 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" Some ELF files have program headers that specify segments that are of zero size. Ignore them, rather than trying to create zero-length ROM blobs for them, because the zero-length blob can falsely trigger the overlapping-ROM-blobs check. Signed-off-by: Peter Maydell Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson Tested-by: Hua Yanghao Message-id: 1502116754-18867-3-git-send-email-peter.maydell@linaro.org --- include/hw/elf_ops.h | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) -- 2.7.4 diff --git a/include/hw/elf_ops.h b/include/hw/elf_ops.h index 2e526d3..d192e7e 100644 --- a/include/hw/elf_ops.h +++ b/include/hw/elf_ops.h @@ -451,14 +451,24 @@ static int glue(load_elf, SZ)(const char *name, int fd, *pentry = ehdr.e_entry - ph->p_vaddr + ph->p_paddr; } - if (load_rom) { - snprintf(label, sizeof(label), "phdr #%d: %s", i, name); - - /* rom_add_elf_program() seize the ownership of 'data' */ - rom_add_elf_program(label, data, file_size, mem_size, addr, as); - } else { - cpu_physical_memory_write(addr, data, file_size); + if (mem_size == 0) { + /* Some ELF files really do have segments of zero size; + * just ignore them rather than trying to create empty + * ROM blobs, because the zero-length blob can falsely + * trigger the overlapping-ROM-blobs check. + */ g_free(data); + } else { + if (load_rom) { + snprintf(label, sizeof(label), "phdr #%d: %s", i, name); + + /* rom_add_elf_program() seize the ownership of 'data' */ + rom_add_elf_program(label, data, file_size, mem_size, + addr, as); + } else { + cpu_physical_memory_write(addr, data, file_size); + g_free(data); + } } total_size += mem_size; From patchwork Mon Sep 4 12:25:49 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 111572 Delivered-To: patch@linaro.org Received: by 10.140.94.166 with SMTP id g35csp1477481qge; Mon, 4 Sep 2017 05:42:24 -0700 (PDT) X-Google-Smtp-Source: ADKCNb6tKKMfSc20ZNCt+A34diLP58ewjFMW5vZ3IJ88Gugpc4KGyFat7ez+ZA5PIjhiG3Uj4bQg X-Received: by 10.200.34.105 with SMTP id p38mr431052qtp.336.1504528944076; Mon, 04 Sep 2017 05:42:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1504528944; cv=none; d=google.com; s=arc-20160816; b=k8rK+RybdH6PJLIwmeCjmJ5iBq6AR2fcEwBqBPL9lUaRG+rUwX4ZUCPvIJqo54BsIP 30rgAEl4zbP+UOrXyF/I/CLg/r/MxUfmhXpwg/n+sw8kEFLJ4pXEUS3dorvHJEQdcXUn zW5f4zyNoWI3ocKJpFX1HaKvEPmDy9AgMhuPdfprdDG0imM72pMXFM1VYpSVOxiE03EM 3UwkashebTMAvUOVRpmFUyFXcqruQURxsTM3Dhcj6B81RejFhvu3XnWOj12+4Y3jOp8l 6vXLPGcsKFKesU0n5dmCOdwKamTVCIlUEmaiJmNvvePLuBgAs0ilEWOE6cwhS6rJapf6 Tkew== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:arc-authentication-results; bh=pXTxdRA6OQfYGkqHW4ovQO1un3KxHpZhf94vsZ0Tavc=; b=mgkhXEVw4GRErZ42gWfqydYT9uodT1gexqVnoWV3/gxxOQneyMgE5dP+O7RnP2WFvL yKYVOs2u3N3EiRUA9DlxLZQ3Vc5Yud5Z2gkmB+GGjp1IlOX8rpAhNi5moEGoZKvlnEIZ h9+tx2XYJ6LhCRelLwvF/H5mRx3UlUw04i3kQHfQQ1gLZB2Fy8tciFvIXaXiu+EHm3Tc lfrNEkf2xnrresJaJZ6cFp/ZxSCwmQ3gXKTRfcCuV9wp2vIxuWDrx8kXZ8hiqxWiErcy CaeZ1HqRY5DIIPFRBxHgwBtuQRqnhVaEnm2uPMAz6TG/PKFj54K5VBd4ZP9WmWfhk+Nz +kXg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id a1si5622504qke.33.2017.09.04.05.42.23 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 04 Sep 2017 05:42:24 -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; Authentication-Results: mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:59620 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1doqhp-0008L1-Qs for patch@linaro.org; Mon, 04 Sep 2017 08:42:21 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52620) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1doqSU-00052j-9s for qemu-devel@nongnu.org; Mon, 04 Sep 2017 08:26:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1doqSG-0004ox-N7 for qemu-devel@nongnu.org; Mon, 04 Sep 2017 08:26:30 -0400 Received: from orth.archaic.org.uk ([2001:8b0:1d0::2]:37122) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1doqSG-0004oE-Ai for qemu-devel@nongnu.org; Mon, 04 Sep 2017 08:26:16 -0400 Received: from pm215 by orth.archaic.org.uk with local (Exim 4.89) (envelope-from ) id 1doqSF-0005Wx-Bk for qemu-devel@nongnu.org; Mon, 04 Sep 2017 13:26:15 +0100 From: Peter Maydell To: qemu-devel@nongnu.org Date: Mon, 4 Sep 2017 13:25:49 +0100 Message-Id: <1504527967-29248-19-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1504527967-29248-1-git-send-email-peter.maydell@linaro.org> References: <1504527967-29248-1-git-send-email-peter.maydell@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2001:8b0:1d0::2 Subject: [Qemu-devel] [PULL 18/36] hw/arm: use defined type name instead of hard-coded string X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 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" From: Philippe Mathieu-Daudé Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Peter Maydell Signed-off-by: Peter Maydell --- hw/arm/armv7m.c | 4 ++-- hw/arm/exynos4210.c | 4 ++-- hw/arm/highbank.c | 11 +++++++---- hw/arm/realview.c | 6 ++++-- hw/arm/vexpress.c | 6 ++++-- hw/arm/xilinx_zynq.c | 14 ++++++++------ 6 files changed, 27 insertions(+), 18 deletions(-) -- 2.7.4 diff --git a/hw/arm/armv7m.c b/hw/arm/armv7m.c index c8a11f2..d2477e8 100644 --- a/hw/arm/armv7m.c +++ b/hw/arm/armv7m.c @@ -146,7 +146,7 @@ static void armv7m_instance_init(Object *obj) &error_abort); memory_region_init(&s->container, obj, "armv7m-container", UINT64_MAX); - object_initialize(&s->nvic, sizeof(s->nvic), "armv7m_nvic"); + object_initialize(&s->nvic, sizeof(s->nvic), TYPE_NVIC); qdev_set_parent_bus(DEVICE(&s->nvic), sysbus_get_default()); object_property_add_alias(obj, "num-irq", OBJECT(&s->nvic), "num-irq", &error_abort); @@ -293,7 +293,7 @@ DeviceState *armv7m_init(MemoryRegion *system_memory, int mem_size, int num_irq, cpu_model = "cortex-m3"; } - armv7m = qdev_create(NULL, "armv7m"); + armv7m = qdev_create(NULL, TYPE_ARMV7M); qdev_prop_set_uint32(armv7m, "num-irq", num_irq); qdev_prop_set_string(armv7m, "cpu-model", cpu_model); object_property_set_link(OBJECT(armv7m), OBJECT(get_system_memory()), diff --git a/hw/arm/exynos4210.c b/hw/arm/exynos4210.c index f9e79f3..ee1438a 100644 --- a/hw/arm/exynos4210.c +++ b/hw/arm/exynos4210.c @@ -33,7 +33,7 @@ #include "hw/arm/arm.h" #include "hw/loader.h" #include "hw/arm/exynos4210.h" -#include "hw/sd/sd.h" +#include "hw/sd/sdhci.h" #include "hw/usb/hcd-ehci.h" #define EXYNOS4210_CHIPID_ADDR 0x10000000 @@ -381,7 +381,7 @@ Exynos4210State *exynos4210_init(MemoryRegion *system_mem) BlockBackend *blk; DriveInfo *di; - dev = qdev_create(NULL, "generic-sdhci"); + dev = qdev_create(NULL, TYPE_SYSBUS_SDHCI); qdev_prop_set_uint32(dev, "capareg", EXYNOS4210_SDHCI_CAPABILITIES); qdev_init_nofail(dev); diff --git a/hw/arm/highbank.c b/hw/arm/highbank.c index 20e60f1..942d5a8 100644 --- a/hw/arm/highbank.c +++ b/hw/arm/highbank.c @@ -31,6 +31,9 @@ #include "exec/address-spaces.h" #include "qemu/error-report.h" #include "hw/char/pl011.h" +#include "hw/ide/ahci.h" +#include "hw/cpu/a9mpcore.h" +#include "hw/cpu/a15mpcore.h" #define SMP_BOOT_ADDR 0x100 #define SMP_BOOT_REG 0x40 @@ -300,10 +303,10 @@ static void calxeda_init(MachineState *machine, enum cxmachines machine_id) busdev = SYS_BUS_DEVICE(dev); sysbus_mmio_map(busdev, 0, 0xfff12000); - dev = qdev_create(NULL, "a9mpcore_priv"); + dev = qdev_create(NULL, TYPE_A9MPCORE_PRIV); break; case CALXEDA_MIDWAY: - dev = qdev_create(NULL, "a15mpcore_priv"); + dev = qdev_create(NULL, TYPE_A15MPCORE_PRIV); break; } qdev_prop_set_uint32(dev, "num-cpu", smp_cpus); @@ -329,7 +332,7 @@ static void calxeda_init(MachineState *machine, enum cxmachines machine_id) sysbus_connect_irq(busdev, 0, pic[18]); pl011_create(0xfff36000, pic[20], serial_hds[0]); - dev = qdev_create(NULL, "highbank-regs"); + dev = qdev_create(NULL, TYPE_HIGHBANK_REGISTERS); qdev_init_nofail(dev); busdev = SYS_BUS_DEVICE(dev); sysbus_mmio_map(busdev, 0, 0xfff3c000); @@ -341,7 +344,7 @@ static void calxeda_init(MachineState *machine, enum cxmachines machine_id) sysbus_create_simple("pl031", 0xfff35000, pic[19]); sysbus_create_simple("pl022", 0xfff39000, pic[23]); - sysbus_create_simple("sysbus-ahci", 0xffe08000, pic[83]); + sysbus_create_simple(TYPE_SYSBUS_AHCI, 0xffe08000, pic[83]); if (nd_table[0].used) { qemu_check_nic_model(&nd_table[0], "xgmac"); diff --git a/hw/arm/realview.c b/hw/arm/realview.c index 76ff557..2736156 100644 --- a/hw/arm/realview.c +++ b/hw/arm/realview.c @@ -24,6 +24,8 @@ #include "exec/address-spaces.h" #include "qemu/error-report.h" #include "hw/char/pl011.h" +#include "hw/cpu/a9mpcore.h" +#include "hw/intc/realview_gic.h" #define SMP_BOOT_ADDR 0xe0000000 #define SMP_BOOTREG_ADDR 0x10000030 @@ -172,7 +174,7 @@ static void realview_init(MachineState *machine, sysbus_mmio_map(SYS_BUS_DEVICE(sysctl), 0, 0x10000000); if (is_mpcore) { - dev = qdev_create(NULL, is_pb ? "a9mpcore_priv": "realview_mpcore"); + dev = qdev_create(NULL, is_pb ? TYPE_A9MPCORE_PRIV : "realview_mpcore"); qdev_prop_set_uint32(dev, "num-cpu", smp_cpus); qdev_init_nofail(dev); busdev = SYS_BUS_DEVICE(dev); @@ -186,7 +188,7 @@ static void realview_init(MachineState *machine, } else { uint32_t gic_addr = is_pb ? 0x1e000000 : 0x10040000; /* For now just create the nIRQ GIC, and ignore the others. */ - dev = sysbus_create_simple("realview_gic", gic_addr, cpu_irq[0]); + dev = sysbus_create_simple(TYPE_REALVIEW_GIC, gic_addr, cpu_irq[0]); } for (n = 0; n < 64; n++) { pic[n] = qdev_get_gpio_in(dev, n); diff --git a/hw/arm/vexpress.c b/hw/arm/vexpress.c index 528c65d..571dd36 100644 --- a/hw/arm/vexpress.c +++ b/hw/arm/vexpress.c @@ -40,6 +40,8 @@ #include "qemu/error-report.h" #include #include "hw/char/pl011.h" +#include "hw/cpu/a9mpcore.h" +#include "hw/cpu/a15mpcore.h" #define VEXPRESS_BOARD_ID 0x8e0 #define VEXPRESS_FLASH_SIZE (64 * 1024 * 1024) @@ -293,7 +295,7 @@ static void a9_daughterboard_init(const VexpressMachineState *vms, memory_region_add_subregion(sysmem, 0x60000000, ram); /* 0x1e000000 A9MPCore (SCU) private memory region */ - init_cpus(cpu_model, "a9mpcore_priv", 0x1e000000, pic, vms->secure); + init_cpus(cpu_model, TYPE_A9MPCORE_PRIV, 0x1e000000, pic, vms->secure); /* Daughterboard peripherals : 0x10020000 .. 0x20000000 */ @@ -378,7 +380,7 @@ static void a15_daughterboard_init(const VexpressMachineState *vms, memory_region_add_subregion(sysmem, 0x80000000, ram); /* 0x2c000000 A15MPCore private memory region (GIC) */ - init_cpus(cpu_model, "a15mpcore_priv", 0x2c000000, pic, vms->secure); + init_cpus(cpu_model, TYPE_A15MPCORE_PRIV, 0x2c000000, pic, vms->secure); /* A15 daughterboard peripherals: */ diff --git a/hw/arm/xilinx_zynq.c b/hw/arm/xilinx_zynq.c index 6b11a75..a750959 100644 --- a/hw/arm/xilinx_zynq.c +++ b/hw/arm/xilinx_zynq.c @@ -31,8 +31,10 @@ #include "hw/misc/zynq-xadc.h" #include "hw/ssi/ssi.h" #include "qemu/error-report.h" -#include "hw/sd/sd.h" +#include "hw/sd/sdhci.h" #include "hw/char/cadence_uart.h" +#include "hw/net/cadence_gem.h" +#include "hw/cpu/a9mpcore.h" #define NUM_SPI_FLASHES 4 #define NUM_QSPI_FLASHES 2 @@ -96,9 +98,9 @@ static void gem_init(NICInfo *nd, uint32_t base, qemu_irq irq) DeviceState *dev; SysBusDevice *s; - dev = qdev_create(NULL, "cadence_gem"); + dev = qdev_create(NULL, TYPE_CADENCE_GEM); if (nd->used) { - qemu_check_nic_model(nd, "cadence_gem"); + qemu_check_nic_model(nd, TYPE_CADENCE_GEM); qdev_set_nic_properties(dev, nd); } qdev_init_nofail(dev); @@ -222,7 +224,7 @@ static void zynq_init(MachineState *machine) qdev_init_nofail(dev); sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, 0xF8000000); - dev = qdev_create(NULL, "a9mpcore_priv"); + dev = qdev_create(NULL, TYPE_A9MPCORE_PRIV); qdev_prop_set_uint32(dev, "num-cpu", 1); qdev_init_nofail(dev); busdev = SYS_BUS_DEVICE(dev); @@ -252,7 +254,7 @@ static void zynq_init(MachineState *machine) gem_init(&nd_table[0], 0xE000B000, pic[54-IRQ_OFFSET]); gem_init(&nd_table[1], 0xE000C000, pic[77-IRQ_OFFSET]); - dev = qdev_create(NULL, "generic-sdhci"); + dev = qdev_create(NULL, TYPE_SYSBUS_SDHCI); qdev_init_nofail(dev); sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, 0xE0100000); sysbus_connect_irq(SYS_BUS_DEVICE(dev), 0, pic[56-IRQ_OFFSET]); @@ -263,7 +265,7 @@ static void zynq_init(MachineState *machine) qdev_prop_set_drive(carddev, "drive", blk, &error_fatal); object_property_set_bool(OBJECT(carddev), true, "realized", &error_fatal); - dev = qdev_create(NULL, "generic-sdhci"); + dev = qdev_create(NULL, TYPE_SYSBUS_SDHCI); qdev_init_nofail(dev); sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, 0xE0101000); sysbus_connect_irq(SYS_BUS_DEVICE(dev), 0, pic[79-IRQ_OFFSET]); From patchwork Mon Sep 4 12:25:50 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 111574 Delivered-To: patch@linaro.org Received: by 10.140.94.166 with SMTP id g35csp1479634qge; Mon, 4 Sep 2017 05:44:27 -0700 (PDT) X-Google-Smtp-Source: ADKCNb7Ec5SRJoZW15vwEaLnir41orrsOZbq8dOeBR2KPLLWX1fXii3OQ+0xXNpZ8leouVBPalSK X-Received: by 10.200.38.98 with SMTP id v31mr456258qtv.306.1504529067789; Mon, 04 Sep 2017 05:44:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1504529067; cv=none; d=google.com; s=arc-20160816; b=DnFsbzCUIaigqB7b9nIRHusWQyG+FNu1Ld0XcB9/37Ne0slXkQSQzgvkVbWpeWbUNt U+wvOsIXLOrfrRg3IFe8BH9fDE2V4o7ZdSjkDXMR72UIq3btK21dhsJw81Vju/2vTqpQ G0HN0sz+FCUve8gKEkYw9zOp6xhl2wn7QphfSQF+cYwytp1+B35IyQt0PHBe6VnMd8NV gprF5Bla7wZt60seCxIY3Oci5+Ji+31ot+jWjB3pH28UHaFjHbulq16nQVsf446zh7pC Y+WTteLz77+L+Lr2n/Ng7R3znWeTQ0Q241F5Kn1JcNx4rhCH7CqL49WL7JAF1mLFo1jg CbSA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:arc-authentication-results; bh=hEs0EBGZpvCccP/i92FqGPM36aW2YOq/uMOXnPvc/HY=; b=cKt3C/NrYg4Gpe9/r1sEeWludOLhXCuI1U4arGVAfLsQxTLqybEYA2NB0Q+/7Hj1pU x5DY2pMlX0TeRXC12tqzOKa6hhwANyyMcow3hpA4L0oYIZhuiuQiFiI2mz7seSbE6t9R uXRVn6o6KA8c/w4F3tOe4VL8wIdnOnfrBP8oXAvRilwrXIPMouWP16pnZBWmQit0QBmx AKw/5akVOBMyCDKlS4BDb8PEfai9gNMGa/iXYbtSZfVzfYhOxQQ4eqcyhE+blrXchpkM h59gm0Ko5tiXPyHrepX6CHP6NBdQrWPzWAoi56osMQJcv4CtOBtyfFGFlu5Tz0um20cq qXfA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id o19si4137952qke.143.2017.09.04.05.44.27 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 04 Sep 2017 05:44:27 -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; Authentication-Results: mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:59629 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1doqjp-0001ak-ME for patch@linaro.org; Mon, 04 Sep 2017 08:44:25 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52685) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1doqSX-00055N-0B for qemu-devel@nongnu.org; Mon, 04 Sep 2017 08:26:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1doqSH-0004pv-MX for qemu-devel@nongnu.org; Mon, 04 Sep 2017 08:26:33 -0400 Received: from orth.archaic.org.uk ([2001:8b0:1d0::2]:37122) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1doqSH-0004oE-Ew for qemu-devel@nongnu.org; Mon, 04 Sep 2017 08:26:17 -0400 Received: from pm215 by orth.archaic.org.uk with local (Exim 4.89) (envelope-from ) id 1doqSG-0005XN-7H for qemu-devel@nongnu.org; Mon, 04 Sep 2017 13:26:16 +0100 From: Peter Maydell To: qemu-devel@nongnu.org Date: Mon, 4 Sep 2017 13:25:50 +0100 Message-Id: <1504527967-29248-20-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1504527967-29248-1-git-send-email-peter.maydell@linaro.org> References: <1504527967-29248-1-git-send-email-peter.maydell@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2001:8b0:1d0::2 Subject: [Qemu-devel] [PULL 19/36] hw/arm/virt: add pmu interrupt state X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 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" From: Andrew Jones Mimicking gicv3-maintenance-interrupt, add the PMU's interrupt to CPU state. Signed-off-by: Andrew Jones Reviewed-by: Peter Maydell Message-id: 1500471597-2517-2-git-send-email-drjones@redhat.com Signed-off-by: Peter Maydell --- target/arm/cpu.h | 2 ++ hw/arm/virt.c | 3 +++ target/arm/cpu.c | 2 ++ 3 files changed, 7 insertions(+) -- 2.7.4 diff --git a/target/arm/cpu.h b/target/arm/cpu.h index eabef00..92771d3 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -585,6 +585,8 @@ struct ARMCPU { qemu_irq gt_timer_outputs[NUM_GTIMERS]; /* GPIO output for GICv3 maintenance interrupt signal */ qemu_irq gicv3_maintenance_interrupt; + /* GPIO output for the PMU interrupt */ + qemu_irq pmu_interrupt; /* MemoryRegion to use for secure physical accesses */ MemoryRegion *secure_memory; diff --git a/hw/arm/virt.c b/hw/arm/virt.c index 6b7a0fe..a06ec13 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -610,6 +610,9 @@ static void create_gic(VirtMachineState *vms, qemu_irq *pic) qdev_connect_gpio_out_named(cpudev, "gicv3-maintenance-interrupt", 0, qdev_get_gpio_in(gicdev, ppibase + ARCH_GICV3_MAINT_IRQ)); + qdev_connect_gpio_out_named(cpudev, "pmu-interrupt", 0, + qdev_get_gpio_in(gicdev, ppibase + + VIRTUAL_PMU_IRQ)); sysbus_connect_irq(gicbusdev, i, qdev_get_gpio_in(cpudev, ARM_CPU_IRQ)); sysbus_connect_irq(gicbusdev, i + smp_cpus, diff --git a/target/arm/cpu.c b/target/arm/cpu.c index b241a63..41ae6ba 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -508,6 +508,8 @@ static void arm_cpu_initfn(Object *obj) qdev_init_gpio_out_named(DEVICE(cpu), &cpu->gicv3_maintenance_interrupt, "gicv3-maintenance-interrupt", 1); + qdev_init_gpio_out_named(DEVICE(cpu), &cpu->pmu_interrupt, + "pmu-interrupt", 1); #endif /* DTB consumers generally don't in fact care what the 'compatible' From patchwork Mon Sep 4 12:25:51 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 111581 Delivered-To: patch@linaro.org Received: by 10.140.94.166 with SMTP id g35csp1483013qge; Mon, 4 Sep 2017 05:47:30 -0700 (PDT) X-Google-Smtp-Source: ADKCNb5tNXCtqKY5TseqcSUH1GfC4wvd/JOW1REH7K+i6p1li0BEv5VqQm8l6HnglyQVVwK86zFg X-Received: by 10.200.3.147 with SMTP id t19mr382391qtg.281.1504529250108; Mon, 04 Sep 2017 05:47:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1504529250; cv=none; d=google.com; s=arc-20160816; b=W0C12T6ZrdV0MDQ2ePlLu8rMHDO644H87e6lE4F5xbHPPtHybago06PbOPYQ5gC4ri j2F3qtGnASA9wagirRccx+8NxRxeSYuitMGT7P1Sv0WnOSx2Cz7SSakNeoy5WKVCGYC9 EzMsxYoqc6GtNpseSW+kK0Wvkz1gqP2nFGsTJ3O9JiVQ/wnNH5dzyg+s8bX3a8TAAnM6 Vb1D+S/SiyR6LDQGo1aZMWp3iUOTu6QnSD0cz9vQMUJg1fGpE67zikVe9kZQ9vcFQof1 lp71SsnoXWkY/HFD6y4+CDf+IHLYAs+nQJB95Zu393oWKWA/lyl8SIS/9aNIjOUqy4a1 IeTg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:arc-authentication-results; bh=O0GTkFScVUa1iNuh6q5vpM0Xr8G9Pt3l/Kx1o9QX0OQ=; b=EJeklL/fkHcD8MNJ6bg277P6x/ayHCkA9gltRNk1kkov+WjPtI6A5TFqEqhfqG8ScB VoDaQLEvXlPLswZH5R8a+EoPYX5ugY9yjNWUnnYaBhI7G7ums4bxqr66F/7WP1TTQ1yh 5mFm6KYof35HA6OqqJHGCew9oTDJ0tTYmAG5o3k/4A1hFtuIMTTqcF/EVmwMlbza3NEa uYOyVTUmhvD+1TAYSTxxUmXz80qTJLN2R7zjsLX+yJU2xAeZYxZeT9W1i5KmgkOFXhxR vE12GIqkqrF3UL+4/AIXkQBSralvuQej76V6LrLZm61PoAby8aQL+t6ooPy8TkibnICD aVcg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id q126si5386431qkd.303.2017.09.04.05.47.29 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 04 Sep 2017 05:47:30 -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; Authentication-Results: mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:59646 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1doqml-0003yu-SX for patch@linaro.org; Mon, 04 Sep 2017 08:47:27 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52702) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1doqSY-00056w-4v for qemu-devel@nongnu.org; Mon, 04 Sep 2017 08:26:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1doqSI-0004qN-GL for qemu-devel@nongnu.org; Mon, 04 Sep 2017 08:26:34 -0400 Received: from orth.archaic.org.uk ([2001:8b0:1d0::2]:37124) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1doqSI-0004pl-5Q for qemu-devel@nongnu.org; Mon, 04 Sep 2017 08:26:18 -0400 Received: from pm215 by orth.archaic.org.uk with local (Exim 4.89) (envelope-from ) id 1doqSH-0005Xq-7C for qemu-devel@nongnu.org; Mon, 04 Sep 2017 13:26:17 +0100 From: Peter Maydell To: qemu-devel@nongnu.org Date: Mon, 4 Sep 2017 13:25:51 +0100 Message-Id: <1504527967-29248-21-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1504527967-29248-1-git-send-email-peter.maydell@linaro.org> References: <1504527967-29248-1-git-send-email-peter.maydell@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2001:8b0:1d0::2 Subject: [Qemu-devel] [PULL 20/36] target/arm/kvm: pmu: split init and set-irq stages X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 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" From: Andrew Jones When adding a PMU with a userspace irqchip we skip the set-irq stage of device creation. Split the 'create' function into two functions 'init' and 'set-irq' so they may be called separately. Signed-off-by: Andrew Jones Reviewed-by: Christoffer Dall Message-id: 1500471597-2517-3-git-send-email-drjones@redhat.com Signed-off-by: Peter Maydell --- target/arm/kvm_arm.h | 10 ++++++++-- hw/arm/virt.c | 11 +++++++++-- target/arm/kvm32.c | 8 +++++++- target/arm/kvm64.c | 52 +++++++++++++++++++++++++--------------------------- 4 files changed, 49 insertions(+), 32 deletions(-) -- 2.7.4 diff --git a/target/arm/kvm_arm.h b/target/arm/kvm_arm.h index 633d088..cab5ea9 100644 --- a/target/arm/kvm_arm.h +++ b/target/arm/kvm_arm.h @@ -195,7 +195,8 @@ int kvm_arm_sync_mpstate_to_qemu(ARMCPU *cpu); int kvm_arm_vgic_probe(void); -int kvm_arm_pmu_create(CPUState *cs, int irq); +int kvm_arm_pmu_set_irq(CPUState *cs, int irq); +int kvm_arm_pmu_init(CPUState *cs); #else @@ -204,7 +205,12 @@ static inline int kvm_arm_vgic_probe(void) return 0; } -static inline int kvm_arm_pmu_create(CPUState *cs, int irq) +static inline int kvm_arm_pmu_set_irq(CPUState *cs, int irq) +{ + return 0; +} + +static inline int kvm_arm_pmu_init(CPUState *cs) { return 0; } diff --git a/hw/arm/virt.c b/hw/arm/virt.c index a06ec13..d6e2486 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -492,10 +492,17 @@ static void fdt_add_pmu_nodes(const VirtMachineState *vms) CPU_FOREACH(cpu) { armcpu = ARM_CPU(cpu); - if (!arm_feature(&armcpu->env, ARM_FEATURE_PMU) || - (kvm_enabled() && !kvm_arm_pmu_create(cpu, PPI(VIRTUAL_PMU_IRQ)))) { + if (!arm_feature(&armcpu->env, ARM_FEATURE_PMU)) { return; } + if (kvm_enabled()) { + if (!kvm_arm_pmu_set_irq(cpu, PPI(VIRTUAL_PMU_IRQ))) { + return; + } + if (!kvm_arm_pmu_init(cpu)) { + return; + } + } } if (vms->gic_version == 2) { diff --git a/target/arm/kvm32.c b/target/arm/kvm32.c index 069da0c..e3aab89 100644 --- a/target/arm/kvm32.c +++ b/target/arm/kvm32.c @@ -522,7 +522,13 @@ bool kvm_arm_hw_debug_active(CPUState *cs) return false; } -int kvm_arm_pmu_create(CPUState *cs, int irq) +int kvm_arm_pmu_set_irq(CPUState *cs, int irq) +{ + qemu_log_mask(LOG_UNIMP, "%s: not implemented\n", __func__); + return 0; +} + +int kvm_arm_pmu_init(CPUState *cs) { qemu_log_mask(LOG_UNIMP, "%s: not implemented\n", __func__); return 0; diff --git a/target/arm/kvm64.c b/target/arm/kvm64.c index a16abc8..e26638a 100644 --- a/target/arm/kvm64.c +++ b/target/arm/kvm64.c @@ -381,46 +381,44 @@ static CPUWatchpoint *find_hw_watchpoint(CPUState *cpu, target_ulong addr) return NULL; } -static bool kvm_arm_pmu_support_ctrl(CPUState *cs, struct kvm_device_attr *attr) -{ - return kvm_vcpu_ioctl(cs, KVM_HAS_DEVICE_ATTR, attr) == 0; -} - -int kvm_arm_pmu_create(CPUState *cs, int irq) +static bool kvm_arm_pmu_set_attr(CPUState *cs, struct kvm_device_attr *attr) { int err; - struct kvm_device_attr attr = { - .group = KVM_ARM_VCPU_PMU_V3_CTRL, - .addr = (intptr_t)&irq, - .attr = KVM_ARM_VCPU_PMU_V3_IRQ, - .flags = 0, - }; - - if (!kvm_arm_pmu_support_ctrl(cs, &attr)) { - return 0; + err = kvm_vcpu_ioctl(cs, KVM_HAS_DEVICE_ATTR, attr); + if (err != 0) { + return false; } - err = kvm_vcpu_ioctl(cs, KVM_SET_DEVICE_ATTR, &attr); + err = kvm_vcpu_ioctl(cs, KVM_SET_DEVICE_ATTR, attr); if (err < 0) { fprintf(stderr, "KVM_SET_DEVICE_ATTR failed: %s\n", strerror(-err)); abort(); } - attr.group = KVM_ARM_VCPU_PMU_V3_CTRL; - attr.attr = KVM_ARM_VCPU_PMU_V3_INIT; - attr.addr = 0; - attr.flags = 0; + return true; +} - err = kvm_vcpu_ioctl(cs, KVM_SET_DEVICE_ATTR, &attr); - if (err < 0) { - fprintf(stderr, "KVM_SET_DEVICE_ATTR failed: %s\n", - strerror(-err)); - abort(); - } +int kvm_arm_pmu_init(CPUState *cs) +{ + struct kvm_device_attr attr = { + .group = KVM_ARM_VCPU_PMU_V3_CTRL, + .attr = KVM_ARM_VCPU_PMU_V3_INIT, + }; + + return kvm_arm_pmu_set_attr(cs, &attr); +} + +int kvm_arm_pmu_set_irq(CPUState *cs, int irq) +{ + struct kvm_device_attr attr = { + .group = KVM_ARM_VCPU_PMU_V3_CTRL, + .addr = (intptr_t)&irq, + .attr = KVM_ARM_VCPU_PMU_V3_IRQ, + }; - return 1; + return kvm_arm_pmu_set_attr(cs, &attr); } static inline void set_feature(uint64_t *features, int feature) From patchwork Mon Sep 4 12:25:52 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 111577 Delivered-To: patch@linaro.org Received: by 10.140.94.166 with SMTP id g35csp1480720qge; Mon, 4 Sep 2017 05:45:26 -0700 (PDT) X-Google-Smtp-Source: ADKCNb5g/+q3OspXx7Ni/mRVYy7lC529KiWVIePb+NPiFSuuSfW5hYnGywqrslU1tfUht648rAok X-Received: by 10.55.201.155 with SMTP id m27mr627821qkl.57.1504529126080; Mon, 04 Sep 2017 05:45:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1504529126; cv=none; d=google.com; s=arc-20160816; b=1EVS4aeGwPDeYBz8XGEm8YLCe1SNYVyyO1nYPPkIA4TTurHOYAKFljXjN4Z+870d6D MlQlrDJReeJ4ZLnryk3dTuX2jeoQKZYZHy+0KIkpBTcDsWqrrh3cfsAw1jQ/1I65wiza YdABMoZlMXjk2tmVVd1ssU1uTCIio9BJxqvCoGF7JarBvJTwT+z4ajH73jL/xBONhgfi Sb6X9Q3cM4hE0O7HHJnyaA/Lz581y4ENdSWP/LI4CHkLAhc7U4OGH6xGTCo6MC/lw2JT 5k2FjeUG6k9RKwCLtLpH32WTQwGIdWrlzn9AVjItpmWLVhkFyW3TsbjsBFj7CqQkBHaP Xwyg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:arc-authentication-results; bh=/FGxQCT9QvaCiwY2Tb9zbWvh1T0a+ptkHvr9E4ChVss=; b=XScMJiHsk7X7JRCN9inXo+S6IeCxAuFa0+Jh02K+LnMaUaUrC5Nv02YrEj0GXfvgZ0 /ahah6+Ck5IlbUxGDWuxT3noXEld3PtMkThGO778vpgXnXA96MjmA21Z67vwRz8E6pdd 3J+6gNG/vSl6LCSJzUZROEli1jmblvJs3QnUTNApJWCK36IAqWCSaudMUczuT4PZX7Ky wdbwEVFhGPont/4W3R6wNXEcjC2BROfdFjCi7Gc8vBjo2+xh9tcZrp8w+h0b+zlI/lnq IUCecLOJSJooIng45QBTMIMNQD6dZIj6Q5ALQbmG9NT7EAxyncHzxDEUf2KGU8CrD83M LtLQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id t38si6970131qtj.42.2017.09.04.05.45.25 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 04 Sep 2017 05:45:26 -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; Authentication-Results: mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:59632 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1doqkm-0002KV-1V for patch@linaro.org; Mon, 04 Sep 2017 08:45:24 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52697) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1doqSX-00056l-VL for qemu-devel@nongnu.org; Mon, 04 Sep 2017 08:26:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1doqSJ-0004qq-DA for qemu-devel@nongnu.org; Mon, 04 Sep 2017 08:26:33 -0400 Received: from orth.archaic.org.uk ([2001:8b0:1d0::2]:37124) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1doqSJ-0004pl-5m for qemu-devel@nongnu.org; Mon, 04 Sep 2017 08:26:19 -0400 Received: from pm215 by orth.archaic.org.uk with local (Exim 4.89) (envelope-from ) id 1doqSI-0005YG-1F for qemu-devel@nongnu.org; Mon, 04 Sep 2017 13:26:18 +0100 From: Peter Maydell To: qemu-devel@nongnu.org Date: Mon, 4 Sep 2017 13:25:52 +0100 Message-Id: <1504527967-29248-22-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1504527967-29248-1-git-send-email-peter.maydell@linaro.org> References: <1504527967-29248-1-git-send-email-peter.maydell@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2001:8b0:1d0::2 Subject: [Qemu-devel] [PULL 21/36] hw/arm/virt: allow pmu instantiation with userspace irqchip X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 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" From: Andrew Jones Move the in-kernel-irqchip test to only guard the set-irq stage, not the init stage of the PMU. Also add the PMU to the KVM device irq line synchronization to enable its use. Signed-off-by: Andrew Jones Reviewed-by: Christoffer Dall Message-id: 1500471597-2517-4-git-send-email-drjones@redhat.com Reviewed-by: Peter Maydell Signed-off-by: Peter Maydell --- hw/arm/virt.c | 3 ++- target/arm/kvm.c | 6 +++++- target/arm/kvm64.c | 3 +-- 3 files changed, 8 insertions(+), 4 deletions(-) -- 2.7.4 diff --git a/hw/arm/virt.c b/hw/arm/virt.c index d6e2486..999f448 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -496,7 +496,8 @@ static void fdt_add_pmu_nodes(const VirtMachineState *vms) return; } if (kvm_enabled()) { - if (!kvm_arm_pmu_set_irq(cpu, PPI(VIRTUAL_PMU_IRQ))) { + if (kvm_irqchip_in_kernel() && + !kvm_arm_pmu_set_irq(cpu, PPI(VIRTUAL_PMU_IRQ))) { return; } if (!kvm_arm_pmu_init(cpu)) { diff --git a/target/arm/kvm.c b/target/arm/kvm.c index 7c17f0d..211a7bf 100644 --- a/target/arm/kvm.c +++ b/target/arm/kvm.c @@ -567,7 +567,11 @@ MemTxAttrs kvm_arch_post_run(CPUState *cs, struct kvm_run *run) switched_level &= ~KVM_ARM_DEV_EL1_PTIMER; } - /* XXX PMU IRQ is missing */ + if (switched_level & KVM_ARM_DEV_PMU) { + qemu_set_irq(cpu->pmu_interrupt, + !!(run->s.regs.device_irq_level & KVM_ARM_DEV_PMU)); + switched_level &= ~KVM_ARM_DEV_PMU; + } if (switched_level) { qemu_log_mask(LOG_UNIMP, "%s: unhandled in-kernel device IRQ %x\n", diff --git a/target/arm/kvm64.c b/target/arm/kvm64.c index e26638a..ec7d853 100644 --- a/target/arm/kvm64.c +++ b/target/arm/kvm64.c @@ -506,8 +506,7 @@ int kvm_arch_init_vcpu(CPUState *cs) if (!arm_feature(&cpu->env, ARM_FEATURE_AARCH64)) { cpu->kvm_init_features[0] |= 1 << KVM_ARM_VCPU_EL1_32BIT; } - if (!kvm_irqchip_in_kernel() || - !kvm_check_extension(cs->kvm_state, KVM_CAP_ARM_PMU_V3)) { + if (!kvm_check_extension(cs->kvm_state, KVM_CAP_ARM_PMU_V3)) { cpu->has_pmu = false; } if (cpu->has_pmu) { From patchwork Mon Sep 4 12:25:53 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 111573 Delivered-To: patch@linaro.org Received: by 10.140.94.166 with SMTP id g35csp1478982qge; Mon, 4 Sep 2017 05:43:54 -0700 (PDT) X-Google-Smtp-Source: ADKCNb4N9mvabD8ghCZtbLSXCv4kwAnmSspXLxMHT7e2Bgyd602qY3TcD4NThYXgtPHk7tQpRqr+ X-Received: by 10.55.33.216 with SMTP id f85mr668820qki.176.1504529034457; Mon, 04 Sep 2017 05:43:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1504529034; cv=none; d=google.com; s=arc-20160816; b=jC4SVG0hM/3FmvSy+ZUWbxFa77rh5iV6+/pBcNCo8h41nIcWPftoz4fG91PfMyAoFd Nd1Qpa5BzBuW+qik6tB5+nrpDNOKn530s0ivGiJQMYr/Q6NuGGVNKXFPIglQh9YHF39+ 5nd2H5QHOfAo3Sk2zypDo+KvD6tr1oCFnRXChjkD6kjiaff0czyOgE0Cm3t4eyUYuOwh 0H5ObKMR+Nv+SyeT8Hbes89h2PcHiOIpzg3jg7B/3HzmSkwdaks2vs0ivKJSJEpC1bUL Q5PH+bjU1b3d0KMVKfPsXTssf58JYdNAbjA21S7f1rjb5Sk6cCsCdItsIsmFVe+zJjmQ fs2w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:arc-authentication-results; bh=SOgx7t7wdzA8jvuf5cpTQxIfjXMxX1XRX1pJ3Orh7xE=; b=TFcNV3/MOiTbFJfMegN+Yw8f4Mzk8JQ628+EWyGdbt0e3pUS4Fg86dGoXXaiIeKMV8 az5SZ8SFQxUmcRA1MYs8LgAXq6DUpJwUTGwa3rcOxCR8DpxiLgbLE0Yt4bJTl8BY000t +q6OKjBoF+kxaMguNXKJAQ7yPnQbpsyw3rtXOYk90QwMzFFGSiouyf2rGPMqdFmVJX+F 5OITLe9sFbwP4BP+QjtcHvL39tVfvwZlFTn5S9Alx5zmTAXBZ0FXrmSy/4128zmX8+If /5szDOyKeHjHysQ2DumJ2JS/O66aA2M9Wc4Gv9+Ev9vK0vzS0uCsBd+a0c7/OwJZ26/1 j1zQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id o128si5499008qkc.39.2017.09.04.05.43.54 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 04 Sep 2017 05:43:54 -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; Authentication-Results: mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:59627 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1doqjI-0001AF-86 for patch@linaro.org; Mon, 04 Sep 2017 08:43:52 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52712) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1doqSY-00057f-NW for qemu-devel@nongnu.org; Mon, 04 Sep 2017 08:26:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1doqSK-0004rc-AM for qemu-devel@nongnu.org; Mon, 04 Sep 2017 08:26:34 -0400 Received: from orth.archaic.org.uk ([2001:8b0:1d0::2]:37126) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1doqSK-0004qw-2a for qemu-devel@nongnu.org; Mon, 04 Sep 2017 08:26:20 -0400 Received: from pm215 by orth.archaic.org.uk with local (Exim 4.89) (envelope-from ) id 1doqSJ-0005Yk-4B for qemu-devel@nongnu.org; Mon, 04 Sep 2017 13:26:19 +0100 From: Peter Maydell To: qemu-devel@nongnu.org Date: Mon, 4 Sep 2017 13:25:53 +0100 Message-Id: <1504527967-29248-23-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1504527967-29248-1-git-send-email-peter.maydell@linaro.org> References: <1504527967-29248-1-git-send-email-peter.maydell@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2001:8b0:1d0::2 Subject: [Qemu-devel] [PULL 22/36] target/arm/kvm: pmu: improve error handling X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 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" From: Andrew Jones If a KVM PMU init or set-irq attr call fails we just silently stop the PMU DT node generation. The only way they could fail, though, is if the attr's respective KVM has-attr call fails. But that should never happen if KVM advertises the PMU capability, because both attrs have been available since the capability was introduced. Let's just abort if this should-never-happen stuff does happen, because, if it does, then something is obviously horribly wrong. Signed-off-by: Andrew Jones Reviewed-by: Christoffer Dall Message-id: 1500471597-2517-5-git-send-email-drjones@redhat.com Reviewed-by: Peter Maydell Signed-off-by: Peter Maydell --- target/arm/kvm_arm.h | 15 ++++----------- hw/arm/virt.c | 9 +++------ target/arm/kvm32.c | 3 +-- target/arm/kvm64.c | 28 ++++++++++++++++++++-------- 4 files changed, 28 insertions(+), 27 deletions(-) -- 2.7.4 diff --git a/target/arm/kvm_arm.h b/target/arm/kvm_arm.h index cab5ea9..ff53e9f 100644 --- a/target/arm/kvm_arm.h +++ b/target/arm/kvm_arm.h @@ -195,8 +195,8 @@ int kvm_arm_sync_mpstate_to_qemu(ARMCPU *cpu); int kvm_arm_vgic_probe(void); -int kvm_arm_pmu_set_irq(CPUState *cs, int irq); -int kvm_arm_pmu_init(CPUState *cs); +void kvm_arm_pmu_set_irq(CPUState *cs, int irq); +void kvm_arm_pmu_init(CPUState *cs); #else @@ -205,15 +205,8 @@ static inline int kvm_arm_vgic_probe(void) return 0; } -static inline int kvm_arm_pmu_set_irq(CPUState *cs, int irq) -{ - return 0; -} - -static inline int kvm_arm_pmu_init(CPUState *cs) -{ - return 0; -} +static inline void kvm_arm_pmu_set_irq(CPUState *cs, int irq) {} +static inline void kvm_arm_pmu_init(CPUState *cs) {} #endif diff --git a/hw/arm/virt.c b/hw/arm/virt.c index 999f448..fe96557 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -496,13 +496,10 @@ static void fdt_add_pmu_nodes(const VirtMachineState *vms) return; } if (kvm_enabled()) { - if (kvm_irqchip_in_kernel() && - !kvm_arm_pmu_set_irq(cpu, PPI(VIRTUAL_PMU_IRQ))) { - return; - } - if (!kvm_arm_pmu_init(cpu)) { - return; + if (kvm_irqchip_in_kernel()) { + kvm_arm_pmu_set_irq(cpu, PPI(VIRTUAL_PMU_IRQ)); } + kvm_arm_pmu_init(cpu); } } diff --git a/target/arm/kvm32.c b/target/arm/kvm32.c index e3aab89..717a256 100644 --- a/target/arm/kvm32.c +++ b/target/arm/kvm32.c @@ -522,10 +522,9 @@ bool kvm_arm_hw_debug_active(CPUState *cs) return false; } -int kvm_arm_pmu_set_irq(CPUState *cs, int irq) +void kvm_arm_pmu_set_irq(CPUState *cs, int irq) { qemu_log_mask(LOG_UNIMP, "%s: not implemented\n", __func__); - return 0; } int kvm_arm_pmu_init(CPUState *cs) diff --git a/target/arm/kvm64.c b/target/arm/kvm64.c index ec7d853..6554c30 100644 --- a/target/arm/kvm64.c +++ b/target/arm/kvm64.c @@ -387,30 +387,36 @@ static bool kvm_arm_pmu_set_attr(CPUState *cs, struct kvm_device_attr *attr) err = kvm_vcpu_ioctl(cs, KVM_HAS_DEVICE_ATTR, attr); if (err != 0) { + error_report("PMU: KVM_HAS_DEVICE_ATTR: %s", strerror(-err)); return false; } err = kvm_vcpu_ioctl(cs, KVM_SET_DEVICE_ATTR, attr); - if (err < 0) { - fprintf(stderr, "KVM_SET_DEVICE_ATTR failed: %s\n", - strerror(-err)); - abort(); + if (err != 0) { + error_report("PMU: KVM_SET_DEVICE_ATTR: %s", strerror(-err)); + return false; } return true; } -int kvm_arm_pmu_init(CPUState *cs) +void kvm_arm_pmu_init(CPUState *cs) { struct kvm_device_attr attr = { .group = KVM_ARM_VCPU_PMU_V3_CTRL, .attr = KVM_ARM_VCPU_PMU_V3_INIT, }; - return kvm_arm_pmu_set_attr(cs, &attr); + if (!ARM_CPU(cs)->has_pmu) { + return; + } + if (!kvm_arm_pmu_set_attr(cs, &attr)) { + error_report("failed to init PMU"); + abort(); + } } -int kvm_arm_pmu_set_irq(CPUState *cs, int irq) +void kvm_arm_pmu_set_irq(CPUState *cs, int irq) { struct kvm_device_attr attr = { .group = KVM_ARM_VCPU_PMU_V3_CTRL, @@ -418,7 +424,13 @@ int kvm_arm_pmu_set_irq(CPUState *cs, int irq) .attr = KVM_ARM_VCPU_PMU_V3_IRQ, }; - return kvm_arm_pmu_set_attr(cs, &attr); + if (!ARM_CPU(cs)->has_pmu) { + return; + } + if (!kvm_arm_pmu_set_attr(cs, &attr)) { + error_report("failed to set irq for PMU"); + abort(); + } } static inline void set_feature(uint64_t *features, int feature) From patchwork Mon Sep 4 12:25:54 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 111575 Delivered-To: patch@linaro.org Received: by 10.140.94.166 with SMTP id g35csp1480314qge; Mon, 4 Sep 2017 05:45:05 -0700 (PDT) X-Google-Smtp-Source: ADKCNb4+R9LofbGjC6EUlkyKteGfZQ6kZgrp8ccijcIJT41H3l37+2TFTXWzeh7DWuxWHvFWuWKw X-Received: by 10.233.235.17 with SMTP id b17mr578882qkg.254.1504529105228; Mon, 04 Sep 2017 05:45:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1504529105; cv=none; d=google.com; s=arc-20160816; b=pvl43xsEyVyaC8Jh02e6TRKSR27j+YeX80JWmTdugWTSPoulL/snS+RgGvGzsFullY +J5n2JXvt72W/KWxrgF71T3bydnhGgg6NJxHE5lcZhMot2v3+kp6i11LCjKzM9TuET5+ AAYgpBfAtn+nkdspgEOC+tRXw6UxHhiufJ2LMDK/c3HraqFDGyT1F1ZWA8yJTdMgZi2g OQ2CeZ+/PxoKaH452z5YRKS7/MJQKIGMoibUxc0txBYbUbWKSZX3dyvwvXGh0kQnT/Ia qbEBbqn6VzyeQ5NrKdtLgCKKcpw0yuEAZCm0Utg9KzEaEECa7QEnQ76DPKhxG+kH6OOw SgOw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:arc-authentication-results; bh=56uB+996d8o9uCo5QRW705vG3bqhy1plo2Qt5B6vIEM=; b=q01ZTXIxGmKLwWboM6vu/vOq4hlVB1Qbv0Vji6Q5EQH57HZOJTV/Iifz5H/WqRzXnv LsEvYJVmiyNgRGEiRkedKxb8y01rPYFiHcw0J/NDPZEfPUsgs0BNToClvDjMjYbr4jO/ iJ8r5Z3QdkMpKy8fwKvQPhHE6U6272zE8vXP3tjDd9bFjVbHZv6zZo5UmVcjXkUexDNM OygEG3q3bmVvfS2UiOtZKOH2ZqwVOB/HzQLt0pasJHlanxKiVQ2L4GociyIEPjjKFxyH KVy9jZNPGQ/qn7oLzmZB9DycFWXyFO61D7cZ2HHcIBjgjo/IUml3dKxRgbCZ4H28zbQ3 R6Ew== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id x42si2682210qth.250.2017.09.04.05.45.04 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 04 Sep 2017 05:45:05 -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; Authentication-Results: mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:59631 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1doqkR-0002KO-23 for patch@linaro.org; Mon, 04 Sep 2017 08:45:03 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52755) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1doqSb-00058m-4g for qemu-devel@nongnu.org; Mon, 04 Sep 2017 08:26:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1doqSL-0004sQ-Hu for qemu-devel@nongnu.org; Mon, 04 Sep 2017 08:26:37 -0400 Received: from orth.archaic.org.uk ([2001:8b0:1d0::2]:37128) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1doqSL-0004ru-7c for qemu-devel@nongnu.org; Mon, 04 Sep 2017 08:26:21 -0400 Received: from pm215 by orth.archaic.org.uk with local (Exim 4.89) (envelope-from ) id 1doqSK-0005ZA-88 for qemu-devel@nongnu.org; Mon, 04 Sep 2017 13:26:20 +0100 From: Peter Maydell To: qemu-devel@nongnu.org Date: Mon, 4 Sep 2017 13:25:54 +0100 Message-Id: <1504527967-29248-24-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1504527967-29248-1-git-send-email-peter.maydell@linaro.org> References: <1504527967-29248-1-git-send-email-peter.maydell@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2001:8b0:1d0::2 Subject: [Qemu-devel] [PULL 23/36] watchdog: wdt_aspeed: Add support for the reset width register X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 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" From: Andrew Jeffery The reset width register controls how the pulse on the SoC's WDTRST{1,2} pins behaves. A pulse is emitted if the external reset bit is set in WDT_CTRL. On the AST2500 WDT_RESET_WIDTH can consume magic bit patterns to configure push-pull/open-drain and active-high/active-low behaviours and thus needs some special handling in the write path. As some of the capabilities depend on the SoC version a silicon-rev property is introduced, which is used to guard version-specific behaviour. Signed-off-by: Andrew Jeffery Reviewed-by: Cédric Le Goater Signed-off-by: Peter Maydell --- include/hw/watchdog/wdt_aspeed.h | 2 + hw/watchdog/wdt_aspeed.c | 93 +++++++++++++++++++++++++++++++++++----- 2 files changed, 84 insertions(+), 11 deletions(-) -- 2.7.4 diff --git a/include/hw/watchdog/wdt_aspeed.h b/include/hw/watchdog/wdt_aspeed.h index 080c223..7de3e5c 100644 --- a/include/hw/watchdog/wdt_aspeed.h +++ b/include/hw/watchdog/wdt_aspeed.h @@ -27,6 +27,8 @@ typedef struct AspeedWDTState { uint32_t regs[ASPEED_WDT_REGS_MAX]; uint32_t pclk_freq; + uint32_t silicon_rev; + uint32_t ext_pulse_width_mask; } AspeedWDTState; #endif /* ASPEED_WDT_H */ diff --git a/hw/watchdog/wdt_aspeed.c b/hw/watchdog/wdt_aspeed.c index 8bbe579..22bce36 100644 --- a/hw/watchdog/wdt_aspeed.c +++ b/hw/watchdog/wdt_aspeed.c @@ -8,16 +8,19 @@ */ #include "qemu/osdep.h" + +#include "qapi/error.h" #include "qemu/log.h" +#include "qemu/timer.h" #include "sysemu/watchdog.h" +#include "hw/misc/aspeed_scu.h" #include "hw/sysbus.h" -#include "qemu/timer.h" #include "hw/watchdog/wdt_aspeed.h" -#define WDT_STATUS (0x00 / 4) -#define WDT_RELOAD_VALUE (0x04 / 4) -#define WDT_RESTART (0x08 / 4) -#define WDT_CTRL (0x0C / 4) +#define WDT_STATUS (0x00 / 4) +#define WDT_RELOAD_VALUE (0x04 / 4) +#define WDT_RESTART (0x08 / 4) +#define WDT_CTRL (0x0C / 4) #define WDT_CTRL_RESET_MODE_SOC (0x00 << 5) #define WDT_CTRL_RESET_MODE_FULL_CHIP (0x01 << 5) #define WDT_CTRL_1MHZ_CLK BIT(4) @@ -25,18 +28,41 @@ #define WDT_CTRL_WDT_INTR BIT(2) #define WDT_CTRL_RESET_SYSTEM BIT(1) #define WDT_CTRL_ENABLE BIT(0) +#define WDT_RESET_WIDTH (0x18 / 4) +#define WDT_RESET_WIDTH_ACTIVE_HIGH BIT(31) +#define WDT_POLARITY_MASK (0xFF << 24) +#define WDT_ACTIVE_HIGH_MAGIC (0xA5 << 24) +#define WDT_ACTIVE_LOW_MAGIC (0x5A << 24) +#define WDT_RESET_WIDTH_PUSH_PULL BIT(30) +#define WDT_DRIVE_TYPE_MASK (0xFF << 24) +#define WDT_PUSH_PULL_MAGIC (0xA8 << 24) +#define WDT_OPEN_DRAIN_MAGIC (0x8A << 24) -#define WDT_TIMEOUT_STATUS (0x10 / 4) -#define WDT_TIMEOUT_CLEAR (0x14 / 4) -#define WDT_RESET_WDITH (0x18 / 4) +#define WDT_TIMEOUT_STATUS (0x10 / 4) +#define WDT_TIMEOUT_CLEAR (0x14 / 4) -#define WDT_RESTART_MAGIC 0x4755 +#define WDT_RESTART_MAGIC 0x4755 static bool aspeed_wdt_is_enabled(const AspeedWDTState *s) { return s->regs[WDT_CTRL] & WDT_CTRL_ENABLE; } +static bool is_ast2500(const AspeedWDTState *s) +{ + switch (s->silicon_rev) { + case AST2500_A0_SILICON_REV: + case AST2500_A1_SILICON_REV: + return true; + case AST2400_A0_SILICON_REV: + case AST2400_A1_SILICON_REV: + default: + break; + } + + return false; +} + static uint64_t aspeed_wdt_read(void *opaque, hwaddr offset, unsigned size) { AspeedWDTState *s = ASPEED_WDT(opaque); @@ -55,9 +81,10 @@ static uint64_t aspeed_wdt_read(void *opaque, hwaddr offset, unsigned size) return 0; case WDT_CTRL: return s->regs[WDT_CTRL]; + case WDT_RESET_WIDTH: + return s->regs[WDT_RESET_WIDTH]; case WDT_TIMEOUT_STATUS: case WDT_TIMEOUT_CLEAR: - case WDT_RESET_WDITH: qemu_log_mask(LOG_UNIMP, "%s: uninmplemented read at offset 0x%" HWADDR_PRIx "\n", __func__, offset); @@ -119,9 +146,27 @@ static void aspeed_wdt_write(void *opaque, hwaddr offset, uint64_t data, timer_del(s->timer); } break; + case WDT_RESET_WIDTH: + { + uint32_t property = data & WDT_POLARITY_MASK; + + if (property && is_ast2500(s)) { + if (property == WDT_ACTIVE_HIGH_MAGIC) { + s->regs[WDT_RESET_WIDTH] |= WDT_RESET_WIDTH_ACTIVE_HIGH; + } else if (property == WDT_ACTIVE_LOW_MAGIC) { + s->regs[WDT_RESET_WIDTH] &= ~WDT_RESET_WIDTH_ACTIVE_HIGH; + } else if (property == WDT_PUSH_PULL_MAGIC) { + s->regs[WDT_RESET_WIDTH] |= WDT_RESET_WIDTH_PUSH_PULL; + } else if (property == WDT_OPEN_DRAIN_MAGIC) { + s->regs[WDT_RESET_WIDTH] &= ~WDT_RESET_WIDTH_PUSH_PULL; + } + } + s->regs[WDT_RESET_WIDTH] &= ~s->ext_pulse_width_mask; + s->regs[WDT_RESET_WIDTH] |= data & s->ext_pulse_width_mask; + break; + } case WDT_TIMEOUT_STATUS: case WDT_TIMEOUT_CLEAR: - case WDT_RESET_WDITH: qemu_log_mask(LOG_UNIMP, "%s: uninmplemented write at offset 0x%" HWADDR_PRIx "\n", __func__, offset); @@ -167,6 +212,7 @@ static void aspeed_wdt_reset(DeviceState *dev) s->regs[WDT_RELOAD_VALUE] = 0x03EF1480; s->regs[WDT_RESTART] = 0; s->regs[WDT_CTRL] = 0; + s->regs[WDT_RESET_WIDTH] = 0xFF; timer_del(s->timer); } @@ -187,6 +233,25 @@ static void aspeed_wdt_realize(DeviceState *dev, Error **errp) SysBusDevice *sbd = SYS_BUS_DEVICE(dev); AspeedWDTState *s = ASPEED_WDT(dev); + if (!is_supported_silicon_rev(s->silicon_rev)) { + error_setg(errp, "Unknown silicon revision: 0x%" PRIx32, + s->silicon_rev); + return; + } + + switch (s->silicon_rev) { + case AST2400_A0_SILICON_REV: + case AST2400_A1_SILICON_REV: + s->ext_pulse_width_mask = 0xff; + break; + case AST2500_A0_SILICON_REV: + case AST2500_A1_SILICON_REV: + s->ext_pulse_width_mask = 0xfffff; + break; + default: + g_assert_not_reached(); + } + s->timer = timer_new_ns(QEMU_CLOCK_VIRTUAL, aspeed_wdt_timer_expired, dev); /* FIXME: This setting should be derived from the SCU hw strapping @@ -199,6 +264,11 @@ static void aspeed_wdt_realize(DeviceState *dev, Error **errp) sysbus_init_mmio(sbd, &s->iomem); } +static Property aspeed_wdt_properties[] = { + DEFINE_PROP_UINT32("silicon-rev", AspeedWDTState, silicon_rev, 0), + DEFINE_PROP_END_OF_LIST(), +}; + static void aspeed_wdt_class_init(ObjectClass *klass, void *data) { DeviceClass *dc = DEVICE_CLASS(klass); @@ -207,6 +277,7 @@ static void aspeed_wdt_class_init(ObjectClass *klass, void *data) dc->reset = aspeed_wdt_reset; set_bit(DEVICE_CATEGORY_MISC, dc->categories); dc->vmsd = &vmstate_aspeed_wdt; + dc->props = aspeed_wdt_properties; } static const TypeInfo aspeed_wdt_info = { From patchwork Mon Sep 4 12:25:55 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 111578 Delivered-To: patch@linaro.org Received: by 10.140.94.166 with SMTP id g35csp1481971qge; Mon, 4 Sep 2017 05:46:33 -0700 (PDT) X-Google-Smtp-Source: ADKCNb5X/mMxBj8udewEdnlQ2XP7Wu3epE2qkCazxjy488Plk7dznMBywQjw53dhv0K1c2wE2HeQ X-Received: by 10.237.37.14 with SMTP id v14mr526880qtc.116.1504529193027; Mon, 04 Sep 2017 05:46:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1504529193; cv=none; d=google.com; s=arc-20160816; b=Z016Ba9vetB/vmlnlXBz0veqs7tW4iYZ7qDhxF0McvPZX1plml0e5oedUukMBUcTvv CNVBXAR5bbNbntUXQ/nVECgHA0+zzZ+W4XuHvKbTdTSr67mKulKJT/Nox2rDUO0t0ZG5 mwhy0h+R2DulmHOXzN6Mmygv4GJX8CgtUHr3S+hl3SjOmtG6kcHwg9J/LoJoTKfRkoLC TWIKT5CNwRDJIM0YnOC2N18DQLdEbwSxyxqbeKLVXahyv+wzXuxkr7erI8sNkODkyfkv 3tM1UfD1a4jifuboFF0ONdE54tLPrvUglHD5WrWKBmMzzj8orvOx95ohbNpTzkGtp7gl +ihQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:arc-authentication-results; bh=BkqMFhl9/NM7wuP7iAc1Fay96oi0EvZKOO0HxurDXT4=; b=MhUJzLjGhQZygM8GZpWQyAVcUzsbV104M0RB3n3UEZf/FQnKQSPoVw2lso/v9ACvQ4 dkz7T7Jg2Tid1+yIc0d912Oa/pmO0IdbZ0WIt/inGQEsMhynnZ7xJfjSA0TyTEKNfjLj ItFumn+3w3D21ghpeXDWNB+XvpvlhV2yjLl8t3NESVyJnnibQJ2JE43WpRo/ymrlJV2i Wc5nUpCY5q4LulrzpkIBwcmqyPnLlHu8+UDPpRK4vNvUyw3rUm8j/5fCjceAsmDqmM+I EEb93peNIZKqs6C7UNAv654brGDeJSu2HunPj8GItmOjAblXYFLfQHJiBYwdh1+dvNyJ wsQg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id m8si6445746qtg.301.2017.09.04.05.46.32 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 04 Sep 2017 05:46:33 -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; Authentication-Results: mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:59642 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1doqlq-0003a4-Ui for patch@linaro.org; Mon, 04 Sep 2017 08:46:31 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52747) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1doqSa-00058k-UB for qemu-devel@nongnu.org; Mon, 04 Sep 2017 08:26:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1doqSM-0004sw-PW for qemu-devel@nongnu.org; Mon, 04 Sep 2017 08:26:36 -0400 Received: from orth.archaic.org.uk ([2001:8b0:1d0::2]:37128) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1doqSM-0004ru-8V for qemu-devel@nongnu.org; Mon, 04 Sep 2017 08:26:22 -0400 Received: from pm215 by orth.archaic.org.uk with local (Exim 4.89) (envelope-from ) id 1doqSL-0005Za-9r for qemu-devel@nongnu.org; Mon, 04 Sep 2017 13:26:21 +0100 From: Peter Maydell To: qemu-devel@nongnu.org Date: Mon, 4 Sep 2017 13:25:55 +0100 Message-Id: <1504527967-29248-25-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1504527967-29248-1-git-send-email-peter.maydell@linaro.org> References: <1504527967-29248-1-git-send-email-peter.maydell@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2001:8b0:1d0::2 Subject: [Qemu-devel] [PULL 24/36] aspeed_soc: Propagate silicon-rev to watchdog X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 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" From: Andrew Jeffery This is required to configure differences in behaviour between the AST2400 and AST2500 watchdog IPs. Signed-off-by: Andrew Jeffery Reviewed-by: Cédric Le Goater Reviewed-by: Peter Maydell Signed-off-by: Peter Maydell --- hw/arm/aspeed_soc.c | 2 ++ 1 file changed, 2 insertions(+) -- 2.7.4 diff --git a/hw/arm/aspeed_soc.c b/hw/arm/aspeed_soc.c index 5529024..22dcac9 100644 --- a/hw/arm/aspeed_soc.c +++ b/hw/arm/aspeed_soc.c @@ -183,6 +183,8 @@ static void aspeed_soc_init(Object *obj) object_initialize(&s->wdt[i], sizeof(s->wdt[i]), TYPE_ASPEED_WDT); object_property_add_child(obj, "wdt[*]", OBJECT(&s->wdt[i]), NULL); qdev_set_parent_bus(DEVICE(&s->wdt[i]), sysbus_get_default()); + qdev_prop_set_uint32(DEVICE(&s->wdt[i]), "silicon-rev", + sc->info->silicon_rev); } object_initialize(&s->ftgmac100, sizeof(s->ftgmac100), TYPE_FTGMAC100); From patchwork Mon Sep 4 12:25:56 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 111583 Delivered-To: patch@linaro.org Received: by 10.140.94.166 with SMTP id g35csp1485703qge; Mon, 4 Sep 2017 05:50:08 -0700 (PDT) X-Google-Smtp-Source: ADKCNb7vJC32qE/2zQHl6TmqnUgq3Ub3zW69e6i5f20wEDtK64mV1KBEarDVWhQUgsU/NP3UVIVN X-Received: by 10.200.43.188 with SMTP id m57mr517844qtm.192.1504529408808; Mon, 04 Sep 2017 05:50:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1504529408; cv=none; d=google.com; s=arc-20160816; b=D9ir23OCTqFw03+HdnQLnqiB0tUu2JtR1z5dAzWBT4V5FaPVlbaJX2NgxOIlyBZGyA KVG9xhAC55jz8YIRfiON/n8+uK8CY64Jt6Ac2pwUuE3K1khsoqUYWcjAWxTdc/xruAHh rc63LFLyw6/SL8U23EIHdF7eQusrxANgUYDbZHr1Mx44cyT2sfw8ak8Z1y+2zhxxnYZ2 dEoy3TsKXBZbMDTh8Urd8mxe69R7/kjiZi0AvHr/S7IPOTXAQlmQd7Qwebu+ELEACKR8 JHHAtF55cRjBg504Gu3D8ywvJbxHKj3kXlmXZLqhi4allCuhg19ZuzZzC7ZapGIq2utp sulg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:arc-authentication-results; bh=wAPi5UYLfUHoDnewjVb2JJW6E3d+mpuvuoa3V/7gfiA=; b=CLeJkX1D1I/uZMOWKwWAptnOT6MBbYWOU5c9XcO5f9X5P/7e5TjshgZ8lSLgRmQWtl lwJ9H43NFmKpbqYFW4PRZV9HHrpPqIxwriKIoue8p1v2M5sqxr1A8zFPiO1iMFM4d0XD iFvORcXWtOimE1tz/FSE4LzQIMYrXJHj69qqMJlsplzX9RQmTKigvBOxeGZMmnWxK00X 8oPEV98tKUrOUo8OZCvM0fttVM9skSeB6R79o4ekBCjIBQRZBgwo+tSMQNHXQQb4uOPm pMZL2q4q/3P2CUdFkmALsVg3HDL87jPvsNPBq1tjXOl6597xQjhSyiT5kxp2RXa55hKN q8nQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id o35si6914008qte.403.2017.09.04.05.50.08 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 04 Sep 2017 05:50:08 -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; Authentication-Results: mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:59654 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1doqpK-00065P-Lb for patch@linaro.org; Mon, 04 Sep 2017 08:50:06 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52809) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1doqSd-0005At-7y for qemu-devel@nongnu.org; Mon, 04 Sep 2017 08:26:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1doqSO-0004u0-50 for qemu-devel@nongnu.org; Mon, 04 Sep 2017 08:26:39 -0400 Received: from orth.archaic.org.uk ([2001:8b0:1d0::2]:37130) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1doqSN-0004tI-RZ for qemu-devel@nongnu.org; Mon, 04 Sep 2017 08:26:24 -0400 Received: from pm215 by orth.archaic.org.uk with local (Exim 4.89) (envelope-from ) id 1doqSM-0005a3-ST for qemu-devel@nongnu.org; Mon, 04 Sep 2017 13:26:22 +0100 From: Peter Maydell To: qemu-devel@nongnu.org Date: Mon, 4 Sep 2017 13:25:56 +0100 Message-Id: <1504527967-29248-26-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1504527967-29248-1-git-send-email-peter.maydell@linaro.org> References: <1504527967-29248-1-git-send-email-peter.maydell@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2001:8b0:1d0::2 Subject: [Qemu-devel] [PULL 25/36] memory.h: Move MemTxResult type to memattrs.h X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 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" Move the MemTxResult type to memattrs.h. We're going to want to use it in cpu/qom.h, which doesn't want to include all of memory.h. In practice MemTxResult and MemTxAttrs are pretty closely linked since both are used for the new-style read_with_attrs and write_with_attrs callbacks, so memattrs.h is a reasonable home for this rather than creating a whole new header file for it. Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson Reviewed-by: Edgar E. Iglesias Reviewed-by: Alistair Francis --- include/exec/memattrs.h | 10 ++++++++++ include/exec/memory.h | 10 ---------- 2 files changed, 10 insertions(+), 10 deletions(-) -- 2.7.4 diff --git a/include/exec/memattrs.h b/include/exec/memattrs.h index e601061..d4a1642 100644 --- a/include/exec/memattrs.h +++ b/include/exec/memattrs.h @@ -46,4 +46,14 @@ typedef struct MemTxAttrs { */ #define MEMTXATTRS_UNSPECIFIED ((MemTxAttrs) { .unspecified = 1 }) +/* New-style MMIO accessors can indicate that the transaction failed. + * A zero (MEMTX_OK) response means success; anything else is a failure + * of some kind. The memory subsystem will bitwise-OR together results + * if it is synthesizing an operation from multiple smaller accesses. + */ +#define MEMTX_OK 0 +#define MEMTX_ERROR (1U << 0) /* device returned an error */ +#define MEMTX_DECODE_ERROR (1U << 1) /* nothing at that address */ +typedef uint32_t MemTxResult; + #endif diff --git a/include/exec/memory.h b/include/exec/memory.h index 400dd44..1dcd312 100644 --- a/include/exec/memory.h +++ b/include/exec/memory.h @@ -112,16 +112,6 @@ static inline void iommu_notifier_init(IOMMUNotifier *n, IOMMUNotify fn, n->end = end; } -/* New-style MMIO accessors can indicate that the transaction failed. - * A zero (MEMTX_OK) response means success; anything else is a failure - * of some kind. The memory subsystem will bitwise-OR together results - * if it is synthesizing an operation from multiple smaller accesses. - */ -#define MEMTX_OK 0 -#define MEMTX_ERROR (1U << 0) /* device returned an error */ -#define MEMTX_DECODE_ERROR (1U << 1) /* nothing at that address */ -typedef uint32_t MemTxResult; - /* * Memory region callbacks */ From patchwork Mon Sep 4 12:25:57 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 111587 Delivered-To: patch@linaro.org Received: by 10.140.94.166 with SMTP id g35csp1488716qge; Mon, 4 Sep 2017 05:52:57 -0700 (PDT) X-Google-Smtp-Source: ADKCNb6kz4oDXWqTtAw6AG3oexGuAA2JsqZSxuUwo25JmlDChlM0C8bxmV5BhGlI3AVTf/EGf/rI X-Received: by 10.200.39.61 with SMTP id g58mr567173qtg.78.1504529577468; Mon, 04 Sep 2017 05:52:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1504529577; cv=none; d=google.com; s=arc-20160816; b=bK/+5yXUmlkPMgXWImQ2Uzf1vtNEQdYTt7kdymqcpjFqjsLcBbT8rYh9k7ouuEZeCt D8lTzhCemG/8JbKfHA9s7PQ2oK1S15VqHGBoHTrRUP+1vhd7RRdg2TYygFmUaOvRkmca wTleMpnvs15unr1c7Z8r43flTvhQsHAz7X1JfW3B8BajLzIDHqzTiRFNjQnCjXvaIyzN QocENVv/7XTeiJu7A7ilf5MB9Z6auEiROmTlpCsQj4WytTcmogZhr+hPwIk7puccpijY 4JI+F6EVUCixLylnj7P3aDhlmlBuCzI7gli8qqV5nyI2wgRq4hTf7sfj572K9EwZxPdk JCfQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:arc-authentication-results; bh=oFCa2h594oW5DhYfx9VAlHrzF0SXNNorkGlGTkyvfEg=; b=q7+JVogOssUGoRkPkJYk/oxujj6CtDb+wbB+A8u6NYDn7NH6iKxSlq2PHeH00nk69V skxZoZnuwTvV3MIBa1sisCcRyOupLYAdnA9iID+vJtiE2ccdafsMc+pSSzuGsZufrTez 8S+1zrUFbG7/SY7Bth/baabUKnRaGjWbut8eNRt5tfqF60XXZbCOOemM0U9Nveumyee0 Je/8M67KkNTKg8Uu/L91319KdRrfTKmEgReUpACgXHA3yAKYRFvfF0ERmU5FL3ERHQVT Q3+FWJZJbpi8Uj4H82l3Hg9M6LI6jmlig9YXtcVA/qyti6RNafrZGgKJbXWLflRfk1J2 M60g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id 11si6864504qta.394.2017.09.04.05.52.57 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 04 Sep 2017 05:52:57 -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; Authentication-Results: mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:59668 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1doqs3-0008Vt-CH for patch@linaro.org; Mon, 04 Sep 2017 08:52:55 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52817) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1doqSd-0005BG-Lp for qemu-devel@nongnu.org; Mon, 04 Sep 2017 08:26:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1doqSP-0004uj-5C for qemu-devel@nongnu.org; Mon, 04 Sep 2017 08:26:39 -0400 Received: from orth.archaic.org.uk ([2001:8b0:1d0::2]:37130) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1doqSO-0004tI-Sz for qemu-devel@nongnu.org; Mon, 04 Sep 2017 08:26:25 -0400 Received: from pm215 by orth.archaic.org.uk with local (Exim 4.89) (envelope-from ) id 1doqSN-0005aT-Uw for qemu-devel@nongnu.org; Mon, 04 Sep 2017 13:26:23 +0100 From: Peter Maydell To: qemu-devel@nongnu.org Date: Mon, 4 Sep 2017 13:25:57 +0100 Message-Id: <1504527967-29248-27-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1504527967-29248-1-git-send-email-peter.maydell@linaro.org> References: <1504527967-29248-1-git-send-email-peter.maydell@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2001:8b0:1d0::2 Subject: [Qemu-devel] [PULL 26/36] cpu: Define new cpu_transaction_failed() hook X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 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" Currently we have a rather half-baked setup for allowing CPUs to generate exceptions on accesses to invalid memory: the CPU has a cpu_unassigned_access() hook which the memory system calls in unassigned_mem_write() and unassigned_mem_read() if the current_cpu pointer is non-NULL. This was originally designed before we implemented the MemTxResult type that allows memory operations to report a success or failure code, which is why the hook is called right at the bottom of the memory system. The major problem with this is that it means that the hook can be called even when the access was not actually done by the CPU: for instance if the CPU writes to a DMA engine register which causes the DMA engine to begin a transaction which has been set up by the guest to operate on invalid memory then this will casue the CPU to take an exception incorrectly. Another minor problem is that currently if a device returns a transaction error then this won't turn into a CPU exception at all. The right way to do this is to have allow the CPU to respond to memory system transaction failures at the point where the CPU specific code calls into the memory system. Define a new QOM CPU method and utility function cpu_transaction_failed() which is called in these cases. The functionality here overlaps with the existing cpu_unassigned_access() because individual target CPUs will need some work to convert them to the new system. When this transition is complete we can remove the old cpu_unassigned_access() code. Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson Reviewed-by: Edgar E. Iglesias --- include/qom/cpu.h | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) -- 2.7.4 diff --git a/include/qom/cpu.h b/include/qom/cpu.h index b7ac949..08bd868 100644 --- a/include/qom/cpu.h +++ b/include/qom/cpu.h @@ -85,8 +85,11 @@ struct TranslationBlock; * @has_work: Callback for checking if there is work to do. * @do_interrupt: Callback for interrupt handling. * @do_unassigned_access: Callback for unassigned access handling. + * (this is deprecated: new targets should use do_transaction_failed instead) * @do_unaligned_access: Callback for unaligned access handling, if * the target defines #ALIGNED_ONLY. + * @do_transaction_failed: Callback for handling failed memory transactions + * (ie bus faults or external aborts; not MMU faults) * @virtio_is_big_endian: Callback to return %true if a CPU which supports * runtime configurable endianness is currently big-endian. Non-configurable * CPUs can use the default implementation of this method. This method should @@ -153,6 +156,10 @@ typedef struct CPUClass { void (*do_unaligned_access)(CPUState *cpu, vaddr addr, MMUAccessType access_type, int mmu_idx, uintptr_t retaddr); + void (*do_transaction_failed)(CPUState *cpu, hwaddr physaddr, vaddr addr, + unsigned size, MMUAccessType access_type, + int mmu_idx, MemTxAttrs attrs, + MemTxResult response, uintptr_t retaddr); bool (*virtio_is_big_endian)(CPUState *cpu); int (*memory_rw_debug)(CPUState *cpu, vaddr addr, uint8_t *buf, int len, bool is_write); @@ -847,6 +854,21 @@ static inline void cpu_unaligned_access(CPUState *cpu, vaddr addr, cc->do_unaligned_access(cpu, addr, access_type, mmu_idx, retaddr); } + +static inline void cpu_transaction_failed(CPUState *cpu, hwaddr physaddr, + vaddr addr, unsigned size, + MMUAccessType access_type, + int mmu_idx, MemTxAttrs attrs, + MemTxResult response, + uintptr_t retaddr) +{ + CPUClass *cc = CPU_GET_CLASS(cpu); + + if (cc->do_transaction_failed) { + cc->do_transaction_failed(cpu, physaddr, addr, size, access_type, + mmu_idx, attrs, response, retaddr); + } +} #endif #endif /* NEED_CPU_H */ From patchwork Mon Sep 4 12:25:58 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 111576 Delivered-To: patch@linaro.org Received: by 10.140.94.166 with SMTP id g35csp1480414qge; Mon, 4 Sep 2017 05:45:09 -0700 (PDT) X-Google-Smtp-Source: ADKCNb5Uh86tv82Si/2QhDznsfFzH7LO/s7snfIi9N4QFRbL6F+6ql3Sb2r3s4LKrWYjwzCux5hz X-Received: by 10.200.34.232 with SMTP id g37mr383157qta.217.1504529109161; Mon, 04 Sep 2017 05:45:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1504529109; cv=none; d=google.com; s=arc-20160816; b=YIhff7WNGI9BMzQWjQRkzzbpKhCskOrB2FKWN+UANs2W7pSus7ZFFjOas+Hqs+v/9/ mxVB/ASp0NN20SJYk6Uig7R8wvpzDCysr4uG+VYn1eUn7o9IE/YNkfrPt30w+HnG3j1X RFUAb+8kYNC/+u+YUf+eh8Vl9/33qqp3OhGZ7huYDbifEH7c/3pVTnbCU4M1nZnDEhpA yIHlwgz4SfqZFNkf1hcKug48/A7SWTnoKxulWi/qHGXP4uNRzhzJtqFTlrrz/mhXn352 2iBMqeHhDl4i11B/LhcW8yY6sjaefPBA+gxsUkZrYwNNPpRyVaaWZJO/U5q3c3Cfb1OE 0wZQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:arc-authentication-results; bh=WuqpqY79FraI/VIruzzq69jObXCBSjJx2TwxCdeEU/0=; b=lOBOqCwPXCtZ8RnnEAPTW9kOEWJtEnXW6eEUJTxZ651PnzeD/8B+5jDWGYTu9lKGdA d9qysE9rFO1BCKtPhvkTvtrhckHM17BRT3miLwKufDNR90QBNG9W2/9WcwRHJPfpYddR CYB4xwlCNo8VQK42/6QKbUSRRXZ8SF42KGe+fasbKtqJVJ7XoAusKSaggGiAqc3tGqez gHbxDmGcJuxNV8Bu3pSDWFCSpo8xmEd7QZ5ubj5aoMcEaRl+I7T/KC/SFPB8ANmYd9xu GSN36DhWI+AGGeC5NEd4DYEmoJ/i7VlIOCBkjQCsvNJx6GojbSzP/HdvMKQczonTpZhf tFqw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id 11si6853797qtp.509.2017.09.04.05.45.08 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 04 Sep 2017 05:45:09 -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; Authentication-Results: mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:59635 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1doqkV-0002OX-1M for patch@linaro.org; Mon, 04 Sep 2017 08:45:07 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52863) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1doqSg-0005DX-3f for qemu-devel@nongnu.org; Mon, 04 Sep 2017 08:26:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1doqSQ-0004vs-UD for qemu-devel@nongnu.org; Mon, 04 Sep 2017 08:26:42 -0400 Received: from orth.archaic.org.uk ([2001:8b0:1d0::2]:37132) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1doqSQ-0004v8-N6 for qemu-devel@nongnu.org; Mon, 04 Sep 2017 08:26:26 -0400 Received: from pm215 by orth.archaic.org.uk with local (Exim 4.89) (envelope-from ) id 1doqSP-0005aw-Mz for qemu-devel@nongnu.org; Mon, 04 Sep 2017 13:26:25 +0100 From: Peter Maydell To: qemu-devel@nongnu.org Date: Mon, 4 Sep 2017 13:25:58 +0100 Message-Id: <1504527967-29248-28-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1504527967-29248-1-git-send-email-peter.maydell@linaro.org> References: <1504527967-29248-1-git-send-email-peter.maydell@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2001:8b0:1d0::2 Subject: [Qemu-devel] [PULL 27/36] cputlb: Support generating CPU exceptions on memory transaction failures X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 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" Call the new cpu_transaction_failed() hook at the places where CPU generated code interacts with the memory system: io_readx() io_writex() get_page_addr_code() Any access from C code (eg via cpu_physical_memory_rw(), address_space_rw(), ld/st_*_phys()) will *not* trigger CPU exceptions via cpu_transaction_failed(). Handling for transactions failures for this kind of call should be done by using a function which returns a MemTxResult and treating the failure case appropriately in the calling code. In an ideal world we would not generate CPU exceptions for instruction fetch failures in get_page_addr_code() but instead wait until the code translation process tried a load and it failed; however that change would require too great a restructuring and redesign to attempt at this point. Signed-off-by: Peter Maydell Reviewed-by: Edgar E. Iglesias --- softmmu_template.h | 4 ++-- accel/tcg/cputlb.c | 32 ++++++++++++++++++++++++++++++-- 2 files changed, 32 insertions(+), 4 deletions(-) -- 2.7.4 diff --git a/softmmu_template.h b/softmmu_template.h index 4a2b665..d756329 100644 --- a/softmmu_template.h +++ b/softmmu_template.h @@ -101,7 +101,7 @@ static inline DATA_TYPE glue(io_read, SUFFIX)(CPUArchState *env, uintptr_t retaddr) { CPUIOTLBEntry *iotlbentry = &env->iotlb[mmu_idx][index]; - return io_readx(env, iotlbentry, addr, retaddr, DATA_SIZE); + return io_readx(env, iotlbentry, mmu_idx, addr, retaddr, DATA_SIZE); } #endif @@ -262,7 +262,7 @@ static inline void glue(io_write, SUFFIX)(CPUArchState *env, uintptr_t retaddr) { CPUIOTLBEntry *iotlbentry = &env->iotlb[mmu_idx][index]; - return io_writex(env, iotlbentry, val, addr, retaddr, DATA_SIZE); + return io_writex(env, iotlbentry, mmu_idx, val, addr, retaddr, DATA_SIZE); } void helper_le_st_name(CPUArchState *env, target_ulong addr, DATA_TYPE val, diff --git a/accel/tcg/cputlb.c b/accel/tcg/cputlb.c index 85635ae..e72415a 100644 --- a/accel/tcg/cputlb.c +++ b/accel/tcg/cputlb.c @@ -747,6 +747,7 @@ static inline ram_addr_t qemu_ram_addr_from_host_nofail(void *ptr) } static uint64_t io_readx(CPUArchState *env, CPUIOTLBEntry *iotlbentry, + int mmu_idx, target_ulong addr, uintptr_t retaddr, int size) { CPUState *cpu = ENV_GET_CPU(env); @@ -754,6 +755,7 @@ static uint64_t io_readx(CPUArchState *env, CPUIOTLBEntry *iotlbentry, MemoryRegion *mr = iotlb_to_region(cpu, physaddr, iotlbentry->attrs); uint64_t val; bool locked = false; + MemTxResult r; physaddr = (physaddr & TARGET_PAGE_MASK) + addr; cpu->mem_io_pc = retaddr; @@ -767,7 +769,12 @@ static uint64_t io_readx(CPUArchState *env, CPUIOTLBEntry *iotlbentry, qemu_mutex_lock_iothread(); locked = true; } - memory_region_dispatch_read(mr, physaddr, &val, size, iotlbentry->attrs); + r = memory_region_dispatch_read(mr, physaddr, + &val, size, iotlbentry->attrs); + if (r != MEMTX_OK) { + cpu_transaction_failed(cpu, physaddr, addr, size, MMU_DATA_LOAD, + mmu_idx, iotlbentry->attrs, r, retaddr); + } if (locked) { qemu_mutex_unlock_iothread(); } @@ -776,6 +783,7 @@ static uint64_t io_readx(CPUArchState *env, CPUIOTLBEntry *iotlbentry, } static void io_writex(CPUArchState *env, CPUIOTLBEntry *iotlbentry, + int mmu_idx, uint64_t val, target_ulong addr, uintptr_t retaddr, int size) { @@ -783,6 +791,7 @@ static void io_writex(CPUArchState *env, CPUIOTLBEntry *iotlbentry, hwaddr physaddr = iotlbentry->addr; MemoryRegion *mr = iotlb_to_region(cpu, physaddr, iotlbentry->attrs); bool locked = false; + MemTxResult r; physaddr = (physaddr & TARGET_PAGE_MASK) + addr; if (mr != &io_mem_rom && mr != &io_mem_notdirty && !cpu->can_do_io) { @@ -795,7 +804,12 @@ static void io_writex(CPUArchState *env, CPUIOTLBEntry *iotlbentry, qemu_mutex_lock_iothread(); locked = true; } - memory_region_dispatch_write(mr, physaddr, val, size, iotlbentry->attrs); + r = memory_region_dispatch_write(mr, physaddr, + val, size, iotlbentry->attrs); + if (r != MEMTX_OK) { + cpu_transaction_failed(cpu, physaddr, addr, size, MMU_DATA_STORE, + mmu_idx, iotlbentry->attrs, r, retaddr); + } if (locked) { qemu_mutex_unlock_iothread(); } @@ -845,6 +859,7 @@ tb_page_addr_t get_page_addr_code(CPUArchState *env, target_ulong addr) MemoryRegion *mr; CPUState *cpu = ENV_GET_CPU(env); CPUIOTLBEntry *iotlbentry; + hwaddr physaddr; index = (addr >> TARGET_PAGE_BITS) & (CPU_TLB_SIZE - 1); mmu_idx = cpu_mmu_index(env, true); @@ -868,6 +883,19 @@ tb_page_addr_t get_page_addr_code(CPUArchState *env, target_ulong addr) } qemu_mutex_unlock_iothread(); + /* Give the new-style cpu_transaction_failed() hook first chance + * to handle this. + * This is not the ideal place to detect and generate CPU + * exceptions for instruction fetch failure (for instance + * we don't know the length of the access that the CPU would + * use, and it would be better to go ahead and try the access + * and use the MemTXResult it produced). However it is the + * simplest place we have currently available for the check. + */ + physaddr = (iotlbentry->addr & TARGET_PAGE_MASK) + addr; + cpu_transaction_failed(cpu, physaddr, addr, 0, MMU_INST_FETCH, mmu_idx, + iotlbentry->attrs, MEMTX_DECODE_ERROR, 0); + cpu_unassigned_access(cpu, addr, false, true, 0, 4); /* The CPU's unassigned access hook might have longjumped out * with an exception. If it didn't (or there was no hook) then From patchwork Mon Sep 4 12:25:59 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 111585 Delivered-To: patch@linaro.org Received: by 10.140.94.166 with SMTP id g35csp1487120qge; Mon, 4 Sep 2017 05:51:24 -0700 (PDT) X-Google-Smtp-Source: ADKCNb5piE7lz6kJJLJ02URObALeu8knHezfLgS/1Q4SvD+UNd68+M7XPnzfSCXG9XhyR4rMic8o X-Received: by 10.237.37.244 with SMTP id y49mr561072qtc.98.1504529484166; Mon, 04 Sep 2017 05:51:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1504529484; cv=none; d=google.com; s=arc-20160816; b=dMohYvk+Ji838klLlacPbuQequoPTeIBHBs1KYbjQAiYVQPr6PLRY2C4z6Vrp5Nfbj rCEKA/MiQ6CMh+lWVma+ADwMtFVgptBEL5+uruz071Ay0BndM52uxB7B29+Yke4fP+pE 8QuUtj/KwTeEkWCiSIoIxjIrtLbfLSqrT8E/EtLWabxU8us8TwghhrlCKMKWVXNX+5vv ImzeMJXzArzZ8Chr03DT/PE/rA5LnD4xEm1xp40t5bDgioBo4NgSJOJkrZ4P/t2m6hOg cn3V6ez3xULkmIPRctuj1ceoOfTSjhdLmkjiFKSxD6AMrbwDbJynQS3t6QcidV5F/1w3 37Sg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:arc-authentication-results; bh=TDt2btoKcRa574WJ2DiCXfFyQy8R85wFbUxq8IsnETo=; b=prJHyvHtq/w5Vy5orDL6Zm4Hv0Xrdgd3Ewfs3ZRWHmv9RK5ENac3LV5kLwd0EkUEfq F9NI/T+EpThyRavjmuyvuHLhQGFg7htJMM/EqjyXBhZi4QDS1z14JRjT0VlydC1wqxYJ kY39fWgwc/7oJhnhggYow1SXDlsPDQAK5AxTk+zTZx59NH55nsikU9sth5FpYR52PuFr 6NwUAAhzEs9SsgPN1IPobtKH6QK1Tv/iP4i0AmYspJNJl/ujfxz+6Q8WssHjqbjpWPpb q8sQQILQvhTLj1CMjSTAvb0u5xtk6lN6CoZB4Kc+XjVInGSrTIUoVp0guMomlfgJqufu OANQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id j22si4724611qke.222.2017.09.04.05.51.23 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 04 Sep 2017 05:51:24 -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; Authentication-Results: mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:59664 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1doqqY-0007WK-4U for patch@linaro.org; Mon, 04 Sep 2017 08:51:22 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52854) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1doqSf-0005DW-Ta for qemu-devel@nongnu.org; Mon, 04 Sep 2017 08:26:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1doqSR-0004wM-UB for qemu-devel@nongnu.org; Mon, 04 Sep 2017 08:26:41 -0400 Received: from orth.archaic.org.uk ([2001:8b0:1d0::2]:37132) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1doqSR-0004v8-Mk for qemu-devel@nongnu.org; Mon, 04 Sep 2017 08:26:27 -0400 Received: from pm215 by orth.archaic.org.uk with local (Exim 4.89) (envelope-from ) id 1doqSQ-0005bM-GQ for qemu-devel@nongnu.org; Mon, 04 Sep 2017 13:26:26 +0100 From: Peter Maydell To: qemu-devel@nongnu.org Date: Mon, 4 Sep 2017 13:25:59 +0100 Message-Id: <1504527967-29248-29-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1504527967-29248-1-git-send-email-peter.maydell@linaro.org> References: <1504527967-29248-1-git-send-email-peter.maydell@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2001:8b0:1d0::2 Subject: [Qemu-devel] [PULL 28/36] boards.h: Define new flag ignore_memory_transaction_failures X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 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" Define a new MachineClass field ignore_memory_transaction_failures. If this is flag is true then the CPU will ignore memory transaction failures which should cause the CPU to take an exception due to an access to an unassigned physical address; the transaction will instead return zero (for a read) or be ignored (for a write). This should be set only by legacy board models which rely on the old RAZ/WI behaviour for handling devices that QEMU does not yet model. New board models should instead use "unimplemented-device" for all memory ranges where the guest will attempt to probe for a device that QEMU doesn't implement and a stub device is required. We need this for ARM boards, where we're about to implement support for generating external aborts on memory transaction failures. Too many of our legacy board models rely on the RAZ/WI behaviour and we would break currently working guests when their "probe for device" code provoked an external abort rather than a RAZ. Signed-off-by: Peter Maydell --- include/hw/boards.h | 11 +++++++++++ include/qom/cpu.h | 7 ++++++- qom/cpu.c | 7 +++++++ 3 files changed, 24 insertions(+), 1 deletion(-) -- 2.7.4 diff --git a/include/hw/boards.h b/include/hw/boards.h index 3363dd1..7f044d1 100644 --- a/include/hw/boards.h +++ b/include/hw/boards.h @@ -131,6 +131,16 @@ typedef struct { * size than the target architecture's minimum. (Attempting to create * such a CPU will fail.) Note that changing this is a migration * compatibility break for the machine. + * @ignore_memory_transaction_failures: + * If this is flag is true then the CPU will ignore memory transaction + * failures which should cause the CPU to take an exception due to an + * access to an unassigned physical address; the transaction will instead + * return zero (for a read) or be ignored (for a write). This should be + * set only by legacy board models which rely on the old RAZ/WI behaviour + * for handling devices that QEMU does not yet model. New board models + * should instead use "unimplemented-device" for all memory ranges where + * the guest will attempt to probe for a device that QEMU doesn't + * implement and a stub device is required. */ struct MachineClass { /*< private >*/ @@ -171,6 +181,7 @@ struct MachineClass { bool rom_file_has_mr; int minimum_page_bits; bool has_hotpluggable_cpus; + bool ignore_memory_transaction_failures; int numa_mem_align_shift; void (*numa_auto_assign_ram)(MachineClass *mc, NodeInfo *nodes, int nb_nodes, ram_addr_t size); diff --git a/include/qom/cpu.h b/include/qom/cpu.h index 08bd868..995a7be 100644 --- a/include/qom/cpu.h +++ b/include/qom/cpu.h @@ -312,6 +312,9 @@ struct qemu_work_item; * @trace_dstate_delayed: Delayed changes to trace_dstate (includes all changes * to @trace_dstate). * @trace_dstate: Dynamic tracing state of events for this vCPU (bitmask). + * @ignore_memory_transaction_failures: Cached copy of the MachineState + * flag of the same name: allows the board to suppress calling of the + * CPU do_transaction_failed hook function. * * State of one CPU core or thread. */ @@ -398,6 +401,8 @@ struct CPUState { */ bool throttle_thread_scheduled; + bool ignore_memory_transaction_failures; + /* Note that this is accessed at the start of every TB via a negative offset from AREG0. Leave this field at the end so as to make the (absolute value) offset as small as possible. This reduces code @@ -864,7 +869,7 @@ static inline void cpu_transaction_failed(CPUState *cpu, hwaddr physaddr, { CPUClass *cc = CPU_GET_CLASS(cpu); - if (cc->do_transaction_failed) { + if (!cpu->ignore_memory_transaction_failures && cc->do_transaction_failed) { cc->do_transaction_failed(cpu, physaddr, addr, size, access_type, mmu_idx, attrs, response, retaddr); } diff --git a/qom/cpu.c b/qom/cpu.c index deb8880..33f865c 100644 --- a/qom/cpu.c +++ b/qom/cpu.c @@ -29,6 +29,7 @@ #include "exec/cpu-common.h" #include "qemu/error-report.h" #include "sysemu/sysemu.h" +#include "hw/boards.h" #include "hw/qdev-properties.h" #include "trace-root.h" @@ -363,6 +364,12 @@ static void cpu_common_parse_features(const char *typename, char *features, static void cpu_common_realizefn(DeviceState *dev, Error **errp) { CPUState *cpu = CPU(dev); + Object *machine = qdev_get_machine(); + ObjectClass *oc = object_get_class(machine); + MachineClass *mc = MACHINE_CLASS(oc); + + cpu->ignore_memory_transaction_failures = + mc->ignore_memory_transaction_failures; if (dev->hotplugged) { cpu_synchronize_post_init(cpu); From patchwork Mon Sep 4 12:26:00 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 111586 Delivered-To: patch@linaro.org Received: by 10.140.94.166 with SMTP id g35csp1487642qge; Mon, 4 Sep 2017 05:51:55 -0700 (PDT) X-Google-Smtp-Source: ADKCNb4q02fmgvONu0ohXEHYMNIcvb/Ye6B+ZxZFRAwnECVrvLbxu5MFPmxvXmGlVkwtCGnfF9Oo X-Received: by 10.200.10.12 with SMTP id b12mr521966qti.152.1504529515032; Mon, 04 Sep 2017 05:51:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1504529515; cv=none; d=google.com; s=arc-20160816; b=jRq0lobcTas0nBZs+PUcDxqtaEPlFPWAd86cXeFixQZBEPhsQDHw2nyCJddOgLwYoO cOGHEISnkwRAHnY7OosPWGX6DOvVbKeJobAtHugUgubIAeeTd+cbOczv7iJ2c1NlSdF9 n+BthQWQkcvTfgcuBBMVfIbJ9U0ZJsiT4vKIAxJ0F0pP0saLoOItGeTFmvvhDoyGihLG OEOX9WuU/r4GgaASy1On95y8ETx223BzskcMoZckUdqkKF8vlylss7ejnwN5XErnjqpv fPIOsBTs9ygXQS+EOTYKbouumSK8CTKzjp6wxhh2rGV5+ETyZ83jBLXEa+A2l+xJxGsR M8ng== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:arc-authentication-results; bh=IGo/u6P9G6Ui6i6VfbHdUci57+m8xFVkJ7ugLpaccvE=; b=qmITU3pZaVvgRe9YWBFsW27hA+ki6BD6/qfsjkveEALoYvxewZhuAGeWhlR1RnbrNU heiGHnwedA5D9V1A/WzdxuZJXWSnNdtejxd6p5UDsQo/A8+tqSxqhGKc4R1gilGIh17P HsOz6xi5ZQlpAytMKHENmSwzuh6p9UQhsKptaLKQ9qPHDNaeN2p8GYQ3If2/4fI0hEDz E72oPdOOkJqs/SKO0wfbV6gE8ZVrXUkWEoVZ0o9A2TAe3nNkZ30fZoR6m45dirv3QFgR mMNaKWfHh9mO80C06s653RBXSzAN8gxsRgqx1xCNswIk7HJQEuD++hEyELsmuBQyHnG9 DTTg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id j23si6694291qta.372.2017.09.04.05.51.54 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 04 Sep 2017 05:51:55 -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; Authentication-Results: mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:59667 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1doqr2-0007yv-JD for patch@linaro.org; Mon, 04 Sep 2017 08:51:52 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52884) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1doqSh-0005Db-62 for qemu-devel@nongnu.org; Mon, 04 Sep 2017 08:26:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1doqSS-0004wi-Oq for qemu-devel@nongnu.org; Mon, 04 Sep 2017 08:26:43 -0400 Received: from orth.archaic.org.uk ([2001:8b0:1d0::2]:37134) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1doqSS-0004wD-Bh for qemu-devel@nongnu.org; Mon, 04 Sep 2017 08:26:28 -0400 Received: from pm215 by orth.archaic.org.uk with local (Exim 4.89) (envelope-from ) id 1doqSR-0005bo-9L for qemu-devel@nongnu.org; Mon, 04 Sep 2017 13:26:27 +0100 From: Peter Maydell To: qemu-devel@nongnu.org Date: Mon, 4 Sep 2017 13:26:00 +0100 Message-Id: <1504527967-29248-30-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1504527967-29248-1-git-send-email-peter.maydell@linaro.org> References: <1504527967-29248-1-git-send-email-peter.maydell@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2001:8b0:1d0::2 Subject: [Qemu-devel] [PULL 29/36] hw/arm: Set ignore_memory_transaction_failures for most ARM boards X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 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" Set the MachineClass flag ignore_memory_transaction_failures for almost all ARM boards. This means they retain the legacy behaviour that accesses to unimplemented addresses will RAZ/WI rather than aborting, when a subsequent commit adds support for external aborts. The exceptions are: * virt -- we know that guests won't try to prod devices that we don't describe in the device tree or ACPI tables * mps2 -- this board was written to use unimplemented-device for all the ranges with devices we don't yet handle New boards should not set the flag, but instead be written like the mps2. Signed-off-by: Peter Maydell For the Xilinx boards: Reviewed-by: Edgar E. Iglesias --- hw/arm/aspeed.c | 3 +++ hw/arm/collie.c | 1 + hw/arm/cubieboard.c | 1 + hw/arm/digic_boards.c | 1 + hw/arm/exynos4_boards.c | 2 ++ hw/arm/gumstix.c | 2 ++ hw/arm/highbank.c | 2 ++ hw/arm/imx25_pdk.c | 1 + hw/arm/integratorcp.c | 1 + hw/arm/kzm.c | 1 + hw/arm/mainstone.c | 1 + hw/arm/musicpal.c | 1 + hw/arm/netduino2.c | 1 + hw/arm/nseries.c | 2 ++ hw/arm/omap_sx1.c | 2 ++ hw/arm/palm.c | 1 + hw/arm/raspi.c | 1 + hw/arm/realview.c | 4 ++++ hw/arm/sabrelite.c | 1 + hw/arm/spitz.c | 4 ++++ hw/arm/stellaris.c | 2 ++ hw/arm/tosa.c | 1 + hw/arm/versatilepb.c | 2 ++ hw/arm/vexpress.c | 1 + hw/arm/xilinx_zynq.c | 1 + hw/arm/xlnx-ep108.c | 2 ++ hw/arm/z2.c | 1 + 27 files changed, 43 insertions(+) -- 2.7.4 diff --git a/hw/arm/aspeed.c b/hw/arm/aspeed.c index 0c5635f..ab895ad 100644 --- a/hw/arm/aspeed.c +++ b/hw/arm/aspeed.c @@ -270,6 +270,7 @@ static void palmetto_bmc_class_init(ObjectClass *oc, void *data) mc->no_floppy = 1; mc->no_cdrom = 1; mc->no_parallel = 1; + mc->ignore_memory_transaction_failures = true; } static const TypeInfo palmetto_bmc_type = { @@ -302,6 +303,7 @@ static void ast2500_evb_class_init(ObjectClass *oc, void *data) mc->no_floppy = 1; mc->no_cdrom = 1; mc->no_parallel = 1; + mc->ignore_memory_transaction_failures = true; } static const TypeInfo ast2500_evb_type = { @@ -326,6 +328,7 @@ static void romulus_bmc_class_init(ObjectClass *oc, void *data) mc->no_floppy = 1; mc->no_cdrom = 1; mc->no_parallel = 1; + mc->ignore_memory_transaction_failures = true; } static const TypeInfo romulus_bmc_type = { diff --git a/hw/arm/collie.c b/hw/arm/collie.c index 2e69531..8830192 100644 --- a/hw/arm/collie.c +++ b/hw/arm/collie.c @@ -64,6 +64,7 @@ static void collie_machine_init(MachineClass *mc) { mc->desc = "Sharp SL-5500 (Collie) PDA (SA-1110)"; mc->init = collie_init; + mc->ignore_memory_transaction_failures = true; } DEFINE_MACHINE("collie", collie_machine_init) diff --git a/hw/arm/cubieboard.c b/hw/arm/cubieboard.c index b98e1c4..32f1edd 100644 --- a/hw/arm/cubieboard.c +++ b/hw/arm/cubieboard.c @@ -86,6 +86,7 @@ static void cubieboard_machine_init(MachineClass *mc) mc->init = cubieboard_init; mc->block_default_type = IF_IDE; mc->units_per_default_bus = 1; + mc->ignore_memory_transaction_failures = true; } DEFINE_MACHINE("cubieboard", cubieboard_machine_init) diff --git a/hw/arm/digic_boards.c b/hw/arm/digic_boards.c index 520c8e9..9f11dcd 100644 --- a/hw/arm/digic_boards.c +++ b/hw/arm/digic_boards.c @@ -155,6 +155,7 @@ static void canon_a1100_machine_init(MachineClass *mc) { mc->desc = "Canon PowerShot A1100 IS"; mc->init = &canon_a1100_init; + mc->ignore_memory_transaction_failures = true; } DEFINE_MACHINE("canon-a1100", canon_a1100_machine_init) diff --git a/hw/arm/exynos4_boards.c b/hw/arm/exynos4_boards.c index 7c03ed3..f1441ec 100644 --- a/hw/arm/exynos4_boards.c +++ b/hw/arm/exynos4_boards.c @@ -189,6 +189,7 @@ static void nuri_class_init(ObjectClass *oc, void *data) mc->desc = "Samsung NURI board (Exynos4210)"; mc->init = nuri_init; mc->max_cpus = EXYNOS4210_NCPUS; + mc->ignore_memory_transaction_failures = true; } static const TypeInfo nuri_type = { @@ -204,6 +205,7 @@ static void smdkc210_class_init(ObjectClass *oc, void *data) mc->desc = "Samsung SMDKC210 board (Exynos4210)"; mc->init = smdkc210_init; mc->max_cpus = EXYNOS4210_NCPUS; + mc->ignore_memory_transaction_failures = true; } static const TypeInfo smdkc210_type = { diff --git a/hw/arm/gumstix.c b/hw/arm/gumstix.c index d59d9ba..092ce36 100644 --- a/hw/arm/gumstix.c +++ b/hw/arm/gumstix.c @@ -128,6 +128,7 @@ static void connex_class_init(ObjectClass *oc, void *data) mc->desc = "Gumstix Connex (PXA255)"; mc->init = connex_init; + mc->ignore_memory_transaction_failures = true; } static const TypeInfo connex_type = { @@ -142,6 +143,7 @@ static void verdex_class_init(ObjectClass *oc, void *data) mc->desc = "Gumstix Verdex (PXA270)"; mc->init = verdex_init; + mc->ignore_memory_transaction_failures = true; } static const TypeInfo verdex_type = { diff --git a/hw/arm/highbank.c b/hw/arm/highbank.c index 942d5a8..ba27789 100644 --- a/hw/arm/highbank.c +++ b/hw/arm/highbank.c @@ -413,6 +413,7 @@ static void highbank_class_init(ObjectClass *oc, void *data) mc->block_default_type = IF_IDE; mc->units_per_default_bus = 1; mc->max_cpus = 4; + mc->ignore_memory_transaction_failures = true; } static const TypeInfo highbank_type = { @@ -430,6 +431,7 @@ static void midway_class_init(ObjectClass *oc, void *data) mc->block_default_type = IF_IDE; mc->units_per_default_bus = 1; mc->max_cpus = 4; + mc->ignore_memory_transaction_failures = true; } static const TypeInfo midway_type = { diff --git a/hw/arm/imx25_pdk.c b/hw/arm/imx25_pdk.c index 7d42c74..9f3ee14 100644 --- a/hw/arm/imx25_pdk.c +++ b/hw/arm/imx25_pdk.c @@ -148,6 +148,7 @@ static void imx25_pdk_machine_init(MachineClass *mc) { mc->desc = "ARM i.MX25 PDK board (ARM926)"; mc->init = imx25_pdk_init; + mc->ignore_memory_transaction_failures = true; } DEFINE_MACHINE("imx25-pdk", imx25_pdk_machine_init) diff --git a/hw/arm/integratorcp.c b/hw/arm/integratorcp.c index d9530ed..d603af9 100644 --- a/hw/arm/integratorcp.c +++ b/hw/arm/integratorcp.c @@ -681,6 +681,7 @@ static void integratorcp_machine_init(MachineClass *mc) { mc->desc = "ARM Integrator/CP (ARM926EJ-S)"; mc->init = integratorcp_init; + mc->ignore_memory_transaction_failures = true; } DEFINE_MACHINE("integratorcp", integratorcp_machine_init) diff --git a/hw/arm/kzm.c b/hw/arm/kzm.c index 3ed6577..f9c2228 100644 --- a/hw/arm/kzm.c +++ b/hw/arm/kzm.c @@ -142,6 +142,7 @@ static void kzm_machine_init(MachineClass *mc) { mc->desc = "ARM KZM Emulation Baseboard (ARM1136)"; mc->init = kzm_init; + mc->ignore_memory_transaction_failures = true; } DEFINE_MACHINE("kzm", kzm_machine_init) diff --git a/hw/arm/mainstone.c b/hw/arm/mainstone.c index fb268e6..637f52c 100644 --- a/hw/arm/mainstone.c +++ b/hw/arm/mainstone.c @@ -196,6 +196,7 @@ static void mainstone2_machine_init(MachineClass *mc) { mc->desc = "Mainstone II (PXA27x)"; mc->init = mainstone_init; + mc->ignore_memory_transaction_failures = true; } DEFINE_MACHINE("mainstone", mainstone2_machine_init) diff --git a/hw/arm/musicpal.c b/hw/arm/musicpal.c index a8b3d46..ab4ba31 100644 --- a/hw/arm/musicpal.c +++ b/hw/arm/musicpal.c @@ -1718,6 +1718,7 @@ static void musicpal_machine_init(MachineClass *mc) { mc->desc = "Marvell 88w8618 / MusicPal (ARM926EJ-S)"; mc->init = musicpal_init; + mc->ignore_memory_transaction_failures = true; } DEFINE_MACHINE("musicpal", musicpal_machine_init) diff --git a/hw/arm/netduino2.c b/hw/arm/netduino2.c index 3cfe332..9d34d4c 100644 --- a/hw/arm/netduino2.c +++ b/hw/arm/netduino2.c @@ -45,6 +45,7 @@ static void netduino2_machine_init(MachineClass *mc) { mc->desc = "Netduino 2 Machine"; mc->init = netduino2_init; + mc->ignore_memory_transaction_failures = true; } DEFINE_MACHINE("netduino2", netduino2_machine_init) diff --git a/hw/arm/nseries.c b/hw/arm/nseries.c index 503a3b6..a32ac82 100644 --- a/hw/arm/nseries.c +++ b/hw/arm/nseries.c @@ -1425,6 +1425,7 @@ static void n800_class_init(ObjectClass *oc, void *data) mc->desc = "Nokia N800 tablet aka. RX-34 (OMAP2420)"; mc->init = n800_init; mc->default_boot_order = ""; + mc->ignore_memory_transaction_failures = true; } static const TypeInfo n800_type = { @@ -1440,6 +1441,7 @@ static void n810_class_init(ObjectClass *oc, void *data) mc->desc = "Nokia N810 tablet aka. RX-44 (OMAP2420)"; mc->init = n810_init; mc->default_boot_order = ""; + mc->ignore_memory_transaction_failures = true; } static const TypeInfo n810_type = { diff --git a/hw/arm/omap_sx1.c b/hw/arm/omap_sx1.c index 9809106..4535617 100644 --- a/hw/arm/omap_sx1.c +++ b/hw/arm/omap_sx1.c @@ -223,6 +223,7 @@ static void sx1_machine_v2_class_init(ObjectClass *oc, void *data) mc->desc = "Siemens SX1 (OMAP310) V2"; mc->init = sx1_init_v2; + mc->ignore_memory_transaction_failures = true; } static const TypeInfo sx1_machine_v2_type = { @@ -237,6 +238,7 @@ static void sx1_machine_v1_class_init(ObjectClass *oc, void *data) mc->desc = "Siemens SX1 (OMAP310) V1"; mc->init = sx1_init_v1; + mc->ignore_memory_transaction_failures = true; } static const TypeInfo sx1_machine_v1_type = { diff --git a/hw/arm/palm.c b/hw/arm/palm.c index 64cf8ca..bf070a2 100644 --- a/hw/arm/palm.c +++ b/hw/arm/palm.c @@ -274,6 +274,7 @@ static void palmte_machine_init(MachineClass *mc) { mc->desc = "Palm Tungsten|E aka. Cheetah PDA (OMAP310)"; mc->init = palmte_init; + mc->ignore_memory_transaction_failures = true; } DEFINE_MACHINE("cheetah", palmte_machine_init) diff --git a/hw/arm/raspi.c b/hw/arm/raspi.c index 32cdc98..5941c9f 100644 --- a/hw/arm/raspi.c +++ b/hw/arm/raspi.c @@ -168,5 +168,6 @@ static void raspi2_machine_init(MachineClass *mc) mc->no_cdrom = 1; mc->max_cpus = BCM2836_NCPUS; mc->default_ram_size = 1024 * 1024 * 1024; + mc->ignore_memory_transaction_failures = true; }; DEFINE_MACHINE("raspi2", raspi2_machine_init) diff --git a/hw/arm/realview.c b/hw/arm/realview.c index 2736156..f3a49b6 100644 --- a/hw/arm/realview.c +++ b/hw/arm/realview.c @@ -398,6 +398,7 @@ static void realview_eb_class_init(ObjectClass *oc, void *data) mc->desc = "ARM RealView Emulation Baseboard (ARM926EJ-S)"; mc->init = realview_eb_init; mc->block_default_type = IF_SCSI; + mc->ignore_memory_transaction_failures = true; } static const TypeInfo realview_eb_type = { @@ -414,6 +415,7 @@ static void realview_eb_mpcore_class_init(ObjectClass *oc, void *data) mc->init = realview_eb_mpcore_init; mc->block_default_type = IF_SCSI; mc->max_cpus = 4; + mc->ignore_memory_transaction_failures = true; } static const TypeInfo realview_eb_mpcore_type = { @@ -428,6 +430,7 @@ static void realview_pb_a8_class_init(ObjectClass *oc, void *data) mc->desc = "ARM RealView Platform Baseboard for Cortex-A8"; mc->init = realview_pb_a8_init; + mc->ignore_memory_transaction_failures = true; } static const TypeInfo realview_pb_a8_type = { @@ -443,6 +446,7 @@ static void realview_pbx_a9_class_init(ObjectClass *oc, void *data) mc->desc = "ARM RealView Platform Baseboard Explore for Cortex-A9"; mc->init = realview_pbx_a9_init; mc->max_cpus = 4; + mc->ignore_memory_transaction_failures = true; } static const TypeInfo realview_pbx_a9_type = { diff --git a/hw/arm/sabrelite.c b/hw/arm/sabrelite.c index 4e7ac8c..ee140e5 100644 --- a/hw/arm/sabrelite.c +++ b/hw/arm/sabrelite.c @@ -122,6 +122,7 @@ static void sabrelite_machine_init(MachineClass *mc) mc->desc = "Freescale i.MX6 Quad SABRE Lite Board (Cortex A9)"; mc->init = sabrelite_init; mc->max_cpus = FSL_IMX6_NUM_CPUS; + mc->ignore_memory_transaction_failures = true; } DEFINE_MACHINE("sabrelite", sabrelite_machine_init) diff --git a/hw/arm/spitz.c b/hw/arm/spitz.c index 7f588ce..6406421 100644 --- a/hw/arm/spitz.c +++ b/hw/arm/spitz.c @@ -983,6 +983,7 @@ static void akitapda_class_init(ObjectClass *oc, void *data) mc->desc = "Sharp SL-C1000 (Akita) PDA (PXA270)"; mc->init = akita_init; + mc->ignore_memory_transaction_failures = true; } static const TypeInfo akitapda_type = { @@ -998,6 +999,7 @@ static void spitzpda_class_init(ObjectClass *oc, void *data) mc->desc = "Sharp SL-C3000 (Spitz) PDA (PXA270)"; mc->init = spitz_init; mc->block_default_type = IF_IDE; + mc->ignore_memory_transaction_failures = true; } static const TypeInfo spitzpda_type = { @@ -1013,6 +1015,7 @@ static void borzoipda_class_init(ObjectClass *oc, void *data) mc->desc = "Sharp SL-C3100 (Borzoi) PDA (PXA270)"; mc->init = borzoi_init; mc->block_default_type = IF_IDE; + mc->ignore_memory_transaction_failures = true; } static const TypeInfo borzoipda_type = { @@ -1028,6 +1031,7 @@ static void terrierpda_class_init(ObjectClass *oc, void *data) mc->desc = "Sharp SL-C3200 (Terrier) PDA (PXA270)"; mc->init = terrier_init; mc->block_default_type = IF_IDE; + mc->ignore_memory_transaction_failures = true; } static const TypeInfo terrierpda_type = { diff --git a/hw/arm/stellaris.c b/hw/arm/stellaris.c index 408c1a1..b3aad23 100644 --- a/hw/arm/stellaris.c +++ b/hw/arm/stellaris.c @@ -1453,6 +1453,7 @@ static void lm3s811evb_class_init(ObjectClass *oc, void *data) mc->desc = "Stellaris LM3S811EVB"; mc->init = lm3s811evb_init; + mc->ignore_memory_transaction_failures = true; } static const TypeInfo lm3s811evb_type = { @@ -1467,6 +1468,7 @@ static void lm3s6965evb_class_init(ObjectClass *oc, void *data) mc->desc = "Stellaris LM3S6965EVB"; mc->init = lm3s6965evb_init; + mc->ignore_memory_transaction_failures = true; } static const TypeInfo lm3s6965evb_type = { diff --git a/hw/arm/tosa.c b/hw/arm/tosa.c index 8b757ff..1134cf7 100644 --- a/hw/arm/tosa.c +++ b/hw/arm/tosa.c @@ -263,6 +263,7 @@ static void tosapda_machine_init(MachineClass *mc) mc->desc = "Sharp SL-6000 (Tosa) PDA (PXA255)"; mc->init = tosa_init; mc->block_default_type = IF_IDE; + mc->ignore_memory_transaction_failures = true; } DEFINE_MACHINE("tosa", tosapda_machine_init) diff --git a/hw/arm/versatilepb.c b/hw/arm/versatilepb.c index b0e9f5b..76664e4 100644 --- a/hw/arm/versatilepb.c +++ b/hw/arm/versatilepb.c @@ -403,6 +403,7 @@ static void versatilepb_class_init(ObjectClass *oc, void *data) mc->desc = "ARM Versatile/PB (ARM926EJ-S)"; mc->init = vpb_init; mc->block_default_type = IF_SCSI; + mc->ignore_memory_transaction_failures = true; } static const TypeInfo versatilepb_type = { @@ -418,6 +419,7 @@ static void versatileab_class_init(ObjectClass *oc, void *data) mc->desc = "ARM Versatile/AB (ARM926EJ-S)"; mc->init = vab_init; mc->block_default_type = IF_SCSI; + mc->ignore_memory_transaction_failures = true; } static const TypeInfo versatileab_type = { diff --git a/hw/arm/vexpress.c b/hw/arm/vexpress.c index 571dd36..e3acab6 100644 --- a/hw/arm/vexpress.c +++ b/hw/arm/vexpress.c @@ -752,6 +752,7 @@ static void vexpress_class_init(ObjectClass *oc, void *data) mc->desc = "ARM Versatile Express"; mc->init = vexpress_common_init; mc->max_cpus = 4; + mc->ignore_memory_transaction_failures = true; } static void vexpress_a9_class_init(ObjectClass *oc, void *data) diff --git a/hw/arm/xilinx_zynq.c b/hw/arm/xilinx_zynq.c index a750959..3759cf8 100644 --- a/hw/arm/xilinx_zynq.c +++ b/hw/arm/xilinx_zynq.c @@ -326,6 +326,7 @@ static void zynq_machine_init(MachineClass *mc) mc->init = zynq_init; mc->max_cpus = 1; mc->no_sdcard = 1; + mc->ignore_memory_transaction_failures = true; } DEFINE_MACHINE("xilinx-zynq-a9", zynq_machine_init) diff --git a/hw/arm/xlnx-ep108.c b/hw/arm/xlnx-ep108.c index 860780a..c339cd4 100644 --- a/hw/arm/xlnx-ep108.c +++ b/hw/arm/xlnx-ep108.c @@ -122,6 +122,7 @@ static void xlnx_ep108_machine_init(MachineClass *mc) mc->init = xlnx_ep108_init; mc->block_default_type = IF_IDE; mc->units_per_default_bus = 1; + mc->ignore_memory_transaction_failures = true; } DEFINE_MACHINE("xlnx-ep108", xlnx_ep108_machine_init) @@ -132,6 +133,7 @@ static void xlnx_zcu102_machine_init(MachineClass *mc) mc->init = xlnx_ep108_init; mc->block_default_type = IF_IDE; mc->units_per_default_bus = 1; + mc->ignore_memory_transaction_failures = true; } DEFINE_MACHINE("xlnx-zcu102", xlnx_zcu102_machine_init) diff --git a/hw/arm/z2.c b/hw/arm/z2.c index 1607cbd..417bc1a 100644 --- a/hw/arm/z2.c +++ b/hw/arm/z2.c @@ -370,6 +370,7 @@ static void z2_machine_init(MachineClass *mc) { mc->desc = "Zipit Z2 (PXA27x)"; mc->init = z2_init; + mc->ignore_memory_transaction_failures = true; } DEFINE_MACHINE("z2", z2_machine_init) From patchwork Mon Sep 4 12:26:01 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 111584 Delivered-To: patch@linaro.org Received: by 10.140.94.166 with SMTP id g35csp1486266qge; Mon, 4 Sep 2017 05:50:39 -0700 (PDT) X-Google-Smtp-Source: ADKCNb5XjC/WRgNSzZ1OK5J2GRNCh5DiOPcTh847yeCvokzJa+UA36rbTf89aUHNDsG7AxKitYa+ X-Received: by 10.55.122.7 with SMTP id v7mr627246qkc.86.1504529439741; Mon, 04 Sep 2017 05:50:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1504529439; cv=none; d=google.com; s=arc-20160816; b=fr23cV3RtxU8SVB+2vgI1U6Hf/Gfr/BHs5haoo73jQ0dYxLNOtB6utVYxR7MRmjvOk ijNrI3IzyYVIXqNthO5dFedkSTAMWkGcvWaDGAUVkZzdXTAzYWqqUpACF2pylL7rOyt1 /sSTIegYWa3La8milWdsNFKGhG7PsXryU61YxChSy3UNslu5pfrCLkbEukcd3T2NNqKu RJwPQ+xyz9ggUJyP+y7+dXgv09Opk58Hdgd9UuUcR+8ojubvuWLJkr4BZuIVr14RBs97 e2qNZtSmDuIZFmEUl9powa0c21ssVkjlK/QFnLkp6aweeL9Cqy+7oHjefKACc+D9Wseg LCyw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:arc-authentication-results; bh=q5tdh4HG9MDhijCpLMuDgQLaA9YXIz16bvm7gfG9Nj8=; b=gvbpTJdctuh46t8leSu7yQ6VCDTMJIKQRPGoP27rU4PtSxlyWvDmRWMdLV1QNYZ5Nk Uj4zsVXOoBxEEdJ1wrWBe6HFp9CL7e2RboU9DnJhmvZd8ejy//HOC6bG5KDCsHVguH8u EOSaRaFQSCPdsUap/jujlkJbmW3Ws6sEYuI5vESm1zVilI22HT71qHBhujpAtSf9vEwF UkQQVmyvBJJMJKnJ0+YsWDEz70NxO/qD4r2pwb7r112FjWCW2OsfqwBB+dFbHxqB8tTV ohKBsMM74sux/2eGItNUJZoUMuFrn2R5m2RzDNIrTvGOVI5slYGmgEsToZT1emwRP7P3 VphQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id y1si4701502qtj.272.2017.09.04.05.50.39 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 04 Sep 2017 05:50:39 -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; Authentication-Results: mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:59656 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1doqpn-0006U2-0Y for patch@linaro.org; Mon, 04 Sep 2017 08:50:37 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52894) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1doqSh-0005Dc-Dx for qemu-devel@nongnu.org; Mon, 04 Sep 2017 08:26:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1doqST-0004xP-OB for qemu-devel@nongnu.org; Mon, 04 Sep 2017 08:26:43 -0400 Received: from orth.archaic.org.uk ([2001:8b0:1d0::2]:37134) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1doqST-0004wD-F0 for qemu-devel@nongnu.org; Mon, 04 Sep 2017 08:26:29 -0400 Received: from pm215 by orth.archaic.org.uk with local (Exim 4.89) (envelope-from ) id 1doqSS-0005c3-2v for qemu-devel@nongnu.org; Mon, 04 Sep 2017 13:26:28 +0100 From: Peter Maydell To: qemu-devel@nongnu.org Date: Mon, 4 Sep 2017 13:26:01 +0100 Message-Id: <1504527967-29248-31-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1504527967-29248-1-git-send-email-peter.maydell@linaro.org> References: <1504527967-29248-1-git-send-email-peter.maydell@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2001:8b0:1d0::2 Subject: [Qemu-devel] [PULL 30/36] target/arm: Factor out fault delivery code X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 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" We currently have some similar code in tlb_fill() and in arm_cpu_do_unaligned_access() for delivering a data abort or prefetch abort. We're also going to want to do the same thing to handle external aborts. Factor out the common code into a new function deliver_fault(). Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson Acked-by: Edgar E. Iglesias --- target/arm/op_helper.c | 110 +++++++++++++++++++++++++------------------------ 1 file changed, 57 insertions(+), 53 deletions(-) -- 2.7.4 diff --git a/target/arm/op_helper.c b/target/arm/op_helper.c index 5a94a5f..6114597 100644 --- a/target/arm/op_helper.c +++ b/target/arm/op_helper.c @@ -115,6 +115,51 @@ static inline uint32_t merge_syn_data_abort(uint32_t template_syn, return syn; } +static void deliver_fault(ARMCPU *cpu, vaddr addr, MMUAccessType access_type, + uint32_t fsr, uint32_t fsc, ARMMMUFaultInfo *fi) +{ + CPUARMState *env = &cpu->env; + int target_el; + bool same_el; + uint32_t syn, exc; + + target_el = exception_target_el(env); + if (fi->stage2) { + target_el = 2; + env->cp15.hpfar_el2 = extract64(fi->s2addr, 12, 47) << 4; + } + same_el = (arm_current_el(env) == target_el); + + if (fsc == 0x3f) { + /* Caller doesn't have a long-format fault status code. This + * should only happen if this fault will never actually be reported + * to an EL that uses a syndrome register. Check that here. + * 0x3f is a (currently) reserved FSC code, in case the constructed + * syndrome does leak into the guest somehow. + */ + assert(target_el != 2 && !arm_el_is_aa64(env, target_el)); + } + + if (access_type == MMU_INST_FETCH) { + syn = syn_insn_abort(same_el, 0, fi->s1ptw, fsc); + exc = EXCP_PREFETCH_ABORT; + } else { + syn = merge_syn_data_abort(env->exception.syndrome, target_el, + same_el, fi->s1ptw, + access_type == MMU_DATA_STORE, + fsc); + if (access_type == MMU_DATA_STORE + && arm_feature(env, ARM_FEATURE_V6)) { + fsr |= (1 << 11); + } + exc = EXCP_DATA_ABORT; + } + + env->exception.vaddress = addr; + env->exception.fsr = fsr; + raise_exception(env, exc, syn, target_el); +} + /* try to fill the TLB and return an exception if error. If retaddr is * NULL, it means that the function was called in C code (i.e. not * from generated code or from helper.c) @@ -129,23 +174,13 @@ void tlb_fill(CPUState *cs, target_ulong addr, MMUAccessType access_type, ret = arm_tlb_fill(cs, addr, access_type, mmu_idx, &fsr, &fi); if (unlikely(ret)) { ARMCPU *cpu = ARM_CPU(cs); - CPUARMState *env = &cpu->env; - uint32_t syn, exc, fsc; - unsigned int target_el; - bool same_el; + uint32_t fsc; if (retaddr) { /* now we have a real cpu fault */ cpu_restore_state(cs, retaddr); } - target_el = exception_target_el(env); - if (fi.stage2) { - target_el = 2; - env->cp15.hpfar_el2 = extract64(fi.s2addr, 12, 47) << 4; - } - same_el = arm_current_el(env) == target_el; - if (fsr & (1 << 9)) { /* LPAE format fault status register : bottom 6 bits are * status code in the same form as needed for syndrome @@ -153,34 +188,15 @@ void tlb_fill(CPUState *cs, target_ulong addr, MMUAccessType access_type, fsc = extract32(fsr, 0, 6); } else { /* Short format FSR : this fault will never actually be reported - * to an EL that uses a syndrome register. Check that here, - * and use a (currently) reserved FSR code in case the constructed - * syndrome does leak into the guest somehow. + * to an EL that uses a syndrome register. Use a (currently) + * reserved FSR code in case the constructed syndrome does leak + * into the guest somehow. deliver_fault will assert that + * we don't target an EL using the syndrome. */ - assert(target_el != 2 && !arm_el_is_aa64(env, target_el)); fsc = 0x3f; } - /* For insn and data aborts we assume there is no instruction syndrome - * information; this is always true for exceptions reported to EL1. - */ - if (access_type == MMU_INST_FETCH) { - syn = syn_insn_abort(same_el, 0, fi.s1ptw, fsc); - exc = EXCP_PREFETCH_ABORT; - } else { - syn = merge_syn_data_abort(env->exception.syndrome, target_el, - same_el, fi.s1ptw, - access_type == MMU_DATA_STORE, fsc); - if (access_type == MMU_DATA_STORE - && arm_feature(env, ARM_FEATURE_V6)) { - fsr |= (1 << 11); - } - exc = EXCP_DATA_ABORT; - } - - env->exception.vaddress = addr; - env->exception.fsr = fsr; - raise_exception(env, exc, syn, target_el); + deliver_fault(cpu, addr, access_type, fsr, fsc, &fi); } } @@ -191,9 +207,8 @@ void arm_cpu_do_unaligned_access(CPUState *cs, vaddr vaddr, { ARMCPU *cpu = ARM_CPU(cs); CPUARMState *env = &cpu->env; - int target_el; - bool same_el; - uint32_t syn; + uint32_t fsr, fsc; + ARMMMUFaultInfo fi = {}; ARMMMUIdx arm_mmu_idx = core_to_arm_mmu_idx(env, mmu_idx); if (retaddr) { @@ -201,28 +216,17 @@ void arm_cpu_do_unaligned_access(CPUState *cs, vaddr vaddr, cpu_restore_state(cs, retaddr); } - target_el = exception_target_el(env); - same_el = (arm_current_el(env) == target_el); - - env->exception.vaddress = vaddr; - /* the DFSR for an alignment fault depends on whether we're using * the LPAE long descriptor format, or the short descriptor format */ if (arm_s1_regime_using_lpae_format(env, arm_mmu_idx)) { - env->exception.fsr = (1 << 9) | 0x21; + fsr = (1 << 9) | 0x21; } else { - env->exception.fsr = 0x1; - } - - if (access_type == MMU_DATA_STORE && arm_feature(env, ARM_FEATURE_V6)) { - env->exception.fsr |= (1 << 11); + fsr = 0x1; } + fsc = 0x21; - syn = merge_syn_data_abort(env->exception.syndrome, target_el, - same_el, 0, access_type == MMU_DATA_STORE, - 0x21); - raise_exception(env, EXCP_DATA_ABORT, syn, target_el); + deliver_fault(cpu, vaddr, access_type, fsr, fsc, &fi); } #endif /* !defined(CONFIG_USER_ONLY) */ From patchwork Mon Sep 4 12:26:02 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 111590 Delivered-To: patch@linaro.org Received: by 10.140.94.166 with SMTP id g35csp1492056qge; Mon, 4 Sep 2017 05:56:21 -0700 (PDT) X-Google-Smtp-Source: ADKCNb6yzEnUZH2K4/w8sdC2tvIzyGgPK7jLKkr9gUDwpRiZM5tH9gwTvPKguazH6l+oxdSCxDDY X-Received: by 10.200.23.236 with SMTP id r41mr529268qtk.258.1504529781013; Mon, 04 Sep 2017 05:56:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1504529781; cv=none; d=google.com; s=arc-20160816; b=r/LuyfhMJkaiHSVRqvNlkmMEf6mxEgD8fLdPDM2H9BPVUhA+KXwiacXhiEj6sexhjW pzYdJd2FJXZmXCy8Uc3CxZG+t7q5dtDdgHnWXoHX2G8xbxwG6gLKwOK0r7ZB3PVU7WPM DICf4DCOoBpj2mNMdTZqzlomRwY/c2zQMM397Xi/6+Yv0jLzKzSzHsRy4w/OhA/z+WK2 gL0zEQ3JlDjIegiHyDUuU1xrqe4cQyJxdQQ9QK+tp6aqzMmFaadqLsZqaB5OXoNah1In LxHvJ8Ff/lhM7Lpp6MmlJcGhaCPgyaXOBNJrvNXsIxKqaeeOkRU8qFa9mSajUzzn+cVQ kzuQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:arc-authentication-results; bh=2hZ4/+gSr5++lUrr16fodZacO0hjyiD4584hAcEXYJs=; b=hBVL/BV0F/5c/IKq77WkouWR33XbV4yZxM22d7XqQdxP8lGXzqvCLVlO5EYmu2sbR6 bmcErYKSp+ZLmSazopHAEgfgWp3EF3LN8TE/uRUPKPud8Fw8VHM4y4La9ggHxUPkdIVg 4sOi4Uzm5EqBsCEpRMEEbsRpdiAFLPFo4yAw0mityM/NJGMB1qBcAX4VIkj2xEfuKOeW A3zkjEp71wE2lZXWmW/MghvQ8vjwoUVkJ8wg27maiPHqVQH11ds2ApCBtGnMnUyFcIjT idtGGvlfWPHU/PZpG1pgpk0VXoO+WvVVS/1TgOstkMfPMEuUswLkOg0zPjnMPkpIFsyw AyPQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id n5si5439960qkf.251.2017.09.04.05.56.20 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 04 Sep 2017 05:56:21 -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; Authentication-Results: mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:59893 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1doqvK-0002sY-Ro for patch@linaro.org; Mon, 04 Sep 2017 08:56:18 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52882) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1doqSh-0005Da-3s for qemu-devel@nongnu.org; Mon, 04 Sep 2017 08:26:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1doqSU-0004xg-6N for qemu-devel@nongnu.org; Mon, 04 Sep 2017 08:26:43 -0400 Received: from orth.archaic.org.uk ([2001:8b0:1d0::2]:37136) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1doqST-0004xA-VI for qemu-devel@nongnu.org; Mon, 04 Sep 2017 08:26:30 -0400 Received: from pm215 by orth.archaic.org.uk with local (Exim 4.89) (envelope-from ) id 1doqSS-0005cg-UN for qemu-devel@nongnu.org; Mon, 04 Sep 2017 13:26:28 +0100 From: Peter Maydell To: qemu-devel@nongnu.org Date: Mon, 4 Sep 2017 13:26:02 +0100 Message-Id: <1504527967-29248-32-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1504527967-29248-1-git-send-email-peter.maydell@linaro.org> References: <1504527967-29248-1-git-send-email-peter.maydell@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2001:8b0:1d0::2 Subject: [Qemu-devel] [PULL 31/36] target/arm: Allow deliver_fault() caller to specify EA bit X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 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" For external aborts, we will want to be able to specify the EA (external abort type) bit in the syndrome field. Allow callers of deliver_fault() to do that by adding a field to ARMMMUFaultInfo which we use when constructing the syndrome values. Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson Reviewed-by: Edgar E. Iglesias --- target/arm/internals.h | 2 ++ target/arm/op_helper.c | 10 +++++----- 2 files changed, 7 insertions(+), 5 deletions(-) -- 2.7.4 diff --git a/target/arm/internals.h b/target/arm/internals.h index bb06946..461f558 100644 --- a/target/arm/internals.h +++ b/target/arm/internals.h @@ -448,12 +448,14 @@ void arm_handle_psci_call(ARMCPU *cpu); * @s2addr: Address that caused a fault at stage 2 * @stage2: True if we faulted at stage 2 * @s1ptw: True if we faulted at stage 2 while doing a stage 1 page-table walk + * @ea: True if we should set the EA (external abort type) bit in syndrome */ typedef struct ARMMMUFaultInfo ARMMMUFaultInfo; struct ARMMMUFaultInfo { target_ulong s2addr; bool stage2; bool s1ptw; + bool ea; }; /* Do a page table walk and add page to TLB if possible */ diff --git a/target/arm/op_helper.c b/target/arm/op_helper.c index 6114597..8f6db80 100644 --- a/target/arm/op_helper.c +++ b/target/arm/op_helper.c @@ -80,7 +80,7 @@ uint32_t HELPER(neon_tbl)(CPUARMState *env, uint32_t ireg, uint32_t def, static inline uint32_t merge_syn_data_abort(uint32_t template_syn, unsigned int target_el, - bool same_el, + bool same_el, bool ea, bool s1ptw, bool is_write, int fsc) { @@ -99,7 +99,7 @@ static inline uint32_t merge_syn_data_abort(uint32_t template_syn, */ if (!(template_syn & ARM_EL_ISV) || target_el != 2 || s1ptw) { syn = syn_data_abort_no_iss(same_el, - 0, 0, s1ptw, is_write, fsc); + ea, 0, s1ptw, is_write, fsc); } else { /* Fields: IL, ISV, SAS, SSE, SRT, SF and AR come from the template * syndrome created at translation time. @@ -107,7 +107,7 @@ static inline uint32_t merge_syn_data_abort(uint32_t template_syn, */ syn = syn_data_abort_with_iss(same_el, 0, 0, 0, 0, 0, - 0, 0, s1ptw, is_write, fsc, + ea, 0, s1ptw, is_write, fsc, false); /* Merge the runtime syndrome with the template syndrome. */ syn |= template_syn; @@ -141,11 +141,11 @@ static void deliver_fault(ARMCPU *cpu, vaddr addr, MMUAccessType access_type, } if (access_type == MMU_INST_FETCH) { - syn = syn_insn_abort(same_el, 0, fi->s1ptw, fsc); + syn = syn_insn_abort(same_el, fi->ea, fi->s1ptw, fsc); exc = EXCP_PREFETCH_ABORT; } else { syn = merge_syn_data_abort(env->exception.syndrome, target_el, - same_el, fi->s1ptw, + same_el, fi->ea, fi->s1ptw, access_type == MMU_DATA_STORE, fsc); if (access_type == MMU_DATA_STORE From patchwork Mon Sep 4 12:26:03 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 111582 Delivered-To: patch@linaro.org Received: by 10.140.94.166 with SMTP id g35csp1483733qge; Mon, 4 Sep 2017 05:48:15 -0700 (PDT) X-Google-Smtp-Source: ADKCNb6EUUoRfT8VV1ZTxvosv4TmPBR+8Wi/9xnBym+Sd3xsPOTRjKaDPbD1AfFUEhXmikzlsEUS X-Received: by 10.55.20.204 with SMTP id 73mr572126qku.11.1504529295030; Mon, 04 Sep 2017 05:48:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1504529295; cv=none; d=google.com; s=arc-20160816; b=oEMgLVStJjefNPAcXYOlazY01rAlGf3qGFq7zo9EOEAs8ueHHpjkUS5Cq8yiEXXxCt PXHsDr40/k+5aTkSTHrX8ozcMyBDmtF/Noj8wJynp9Xaxy54VP+ZsLAQtzZ2EpZ/QEXH VbE4dBfQZYQREnsNlBWgQYqNIIshWCzeDR+/wS2kVfsCHQM1B8Yt2kn33o7X2O7X01a7 k5S6W0h17/YPcvD+z0aS3f2J9utsj4J1p22TPyu/kOH+W5MYYr2eBPbHasbq30VMR7HD tomfvzOZ5Lv+ywTVqQTVP8KDpLrObhKUATvRUaeC59va8YGSQTwXiEML78qjEwoGKg8O uH6Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:arc-authentication-results; bh=a/Y2RHS2yWp4IgFi4vcAun+wyJxftUF7408d+F9nr/A=; b=nbp32BI/aYXtICkfBkNl3G7TK78P5kzyLshBhKY/GP6zG2KDhlAK1Wc1GEw6P2Sr1L nx1IZz2nVAKwjlMFwvoUIfx0F8OQfEpcF3lfHIYtIG8jZKVOFj3vt5ZzGbYH8X4UOzXv E3PunhzCa3q6A0uCLXtg6cYScZ7UR3W1blLZxi4kIUhgwdXuasBPrhTn9kD2sIOeJLdS 59mT3hlCSfIW4ib2hOGhbyhHb8rVM3EbF5uczfmL6Y5Ju/96HyaA4jHXhLlQnlDNpYh/ oFB5snrV4nl4pP+iCaVj/GLvJ7rf/iwTwYZ3zReBBvnYGE3Iq08jtWOu381Gt/TXtQfT TAXg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id r32si6806349qtk.435.2017.09.04.05.48.14 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 04 Sep 2017 05:48:15 -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; Authentication-Results: mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:59649 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1doqnU-0004nQ-U9 for patch@linaro.org; Mon, 04 Sep 2017 08:48:13 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52911) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1doqSi-0005Dg-Jr for qemu-devel@nongnu.org; Mon, 04 Sep 2017 08:26:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1doqSV-0004yz-5K for qemu-devel@nongnu.org; Mon, 04 Sep 2017 08:26:44 -0400 Received: from orth.archaic.org.uk ([2001:8b0:1d0::2]:37136) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1doqSU-0004xA-Th for qemu-devel@nongnu.org; Mon, 04 Sep 2017 08:26:31 -0400 Received: from pm215 by orth.archaic.org.uk with local (Exim 4.89) (envelope-from ) id 1doqST-0005cx-KQ for qemu-devel@nongnu.org; Mon, 04 Sep 2017 13:26:29 +0100 From: Peter Maydell To: qemu-devel@nongnu.org Date: Mon, 4 Sep 2017 13:26:03 +0100 Message-Id: <1504527967-29248-33-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1504527967-29248-1-git-send-email-peter.maydell@linaro.org> References: <1504527967-29248-1-git-send-email-peter.maydell@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2001:8b0:1d0::2 Subject: [Qemu-devel] [PULL 32/36] target/arm: Implement new do_transaction_failed hook X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 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" Implement the new do_transaction_failed hook for ARM, which should cause the CPU to take a prefetch abort or data abort. Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson Reviewed-by: Edgar E. Iglesias --- target/arm/internals.h | 10 ++++++++++ target/arm/cpu.c | 1 + target/arm/op_helper.c | 43 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 54 insertions(+) -- 2.7.4 diff --git a/target/arm/internals.h b/target/arm/internals.h index 461f558..b100da9 100644 --- a/target/arm/internals.h +++ b/target/arm/internals.h @@ -472,6 +472,16 @@ void arm_cpu_do_unaligned_access(CPUState *cs, vaddr vaddr, MMUAccessType access_type, int mmu_idx, uintptr_t retaddr); +/* arm_cpu_do_transaction_failed: handle a memory system error response + * (eg "no device/memory present at address") by raising an external abort + * exception + */ +void arm_cpu_do_transaction_failed(CPUState *cs, hwaddr physaddr, + vaddr addr, unsigned size, + MMUAccessType access_type, + int mmu_idx, MemTxAttrs attrs, + MemTxResult response, uintptr_t retaddr); + /* Call the EL change hook if one has been registered */ static inline void arm_call_el_change_hook(ARMCPU *cpu) { diff --git a/target/arm/cpu.c b/target/arm/cpu.c index 41ae6ba..a323e6b 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -1667,6 +1667,7 @@ static void arm_cpu_class_init(ObjectClass *oc, void *data) #else cc->do_interrupt = arm_cpu_do_interrupt; cc->do_unaligned_access = arm_cpu_do_unaligned_access; + cc->do_transaction_failed = arm_cpu_do_transaction_failed; cc->get_phys_page_attrs_debug = arm_cpu_get_phys_page_attrs_debug; cc->asidx_from_attrs = arm_asidx_from_attrs; cc->vmsd = &vmstate_arm_cpu; diff --git a/target/arm/op_helper.c b/target/arm/op_helper.c index 8f6db80..d1bca46 100644 --- a/target/arm/op_helper.c +++ b/target/arm/op_helper.c @@ -229,6 +229,49 @@ void arm_cpu_do_unaligned_access(CPUState *cs, vaddr vaddr, deliver_fault(cpu, vaddr, access_type, fsr, fsc, &fi); } +/* arm_cpu_do_transaction_failed: handle a memory system error response + * (eg "no device/memory present at address") by raising an external abort + * exception + */ +void arm_cpu_do_transaction_failed(CPUState *cs, hwaddr physaddr, + vaddr addr, unsigned size, + MMUAccessType access_type, + int mmu_idx, MemTxAttrs attrs, + MemTxResult response, uintptr_t retaddr) +{ + ARMCPU *cpu = ARM_CPU(cs); + CPUARMState *env = &cpu->env; + uint32_t fsr, fsc; + ARMMMUFaultInfo fi = {}; + ARMMMUIdx arm_mmu_idx = core_to_arm_mmu_idx(env, mmu_idx); + + if (retaddr) { + /* now we have a real cpu fault */ + cpu_restore_state(cs, retaddr); + } + + /* The EA bit in syndromes and fault status registers is an + * IMPDEF classification of external aborts. ARM implementations + * usually use this to indicate AXI bus Decode error (0) or + * Slave error (1); in QEMU we follow that. + */ + fi.ea = (response != MEMTX_DECODE_ERROR); + + /* The fault status register format depends on whether we're using + * the LPAE long descriptor format, or the short descriptor format. + */ + if (arm_s1_regime_using_lpae_format(env, arm_mmu_idx)) { + /* long descriptor form, STATUS 0b010000: synchronous ext abort */ + fsr = (fi.ea << 12) | (1 << 9) | 0x10; + } else { + /* short descriptor form, FSR 0b01000 : synchronous ext abort */ + fsr = (fi.ea << 12) | 0x8; + } + fsc = 0x10; + + deliver_fault(cpu, addr, access_type, fsr, fsc, &fi); +} + #endif /* !defined(CONFIG_USER_ONLY) */ uint32_t HELPER(add_setq)(CPUARMState *env, uint32_t a, uint32_t b) From patchwork Mon Sep 4 12:26:04 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 111591 Delivered-To: patch@linaro.org Received: by 10.140.94.166 with SMTP id g35csp1495215qge; Mon, 4 Sep 2017 05:59:19 -0700 (PDT) X-Google-Smtp-Source: ADKCNb6/7bqtDoHtwP4SiW4fnobWfK85XxvtFQK8VmQuEwTk9i5oPpYVEZT1KZKG35XO0j2tME5y X-Received: by 10.55.73.13 with SMTP id w13mr546446qka.259.1504529959022; Mon, 04 Sep 2017 05:59:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1504529959; cv=none; d=google.com; s=arc-20160816; b=X+SbQw6UAMlUnQJvV25Xf2WCuxUIhGFAZpWaNoP5qU4vkV9MW/rzm9dV90UMuwsYHZ 96Vu0zAclToX0y2e9Bgk7O+5pVYa9rbTvlXfFLy4Eok0PbNj9v5JB9nWyZ/t88d098cl 1uPUY4jujo39xOXnvTs2f2re0T8ZuP7EcObH35Qlz6nRYwkYOfaCt5awheJL2ndCJw2I 1Y0jtTfQizR/Fh1JeCANuNIUpue1ad8OjeVELDedaN2ZCyWztH7e6QUz/1koam9uG9Il 7gwTXAKAa64MHtZj6N6o1oFD5E+ANFgA7dA5djgnK7L4U5MX64SMW/pdCMYjzfAQE/OL tjCg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:arc-authentication-results; bh=EV6Pfgh3qvi1SCFL3mRglU8i0/Vqq4LCJwMJ5LORC8I=; b=WJsgbqejrrs66unFaIcC1g5ioL078YPMnwWwqNN1RHCvDydlCTrCcehSXTcbeMyMrH UAuXAREQaRybTGoWjk4O+izfEPXshfczlVVEZiBfO0u/qlr3jCkn5pz/r33GhA0+BKuY wofRyJ+oeUPKpQZpRim+Wr+oJqNyB4ZRB/ulrS8KlptrBmh/Lg8pNio9DLpmSYuHzRpA yk7CFa9qmRQYxMZqIWaw902DPV+GNHWfzwa37gxChVmtZzyZ7vexVKhAmcwru32CbYl8 QrBnkr3kiDU9Qb6zpZmIOYNSUxPN3A7jfOap4hKQzDnW04ukXfywygIMchhDZFSms82k 6W1w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id p3si5437257qki.76.2017.09.04.05.59.18 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 04 Sep 2017 05:59:19 -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; Authentication-Results: mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:60390 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1doqyC-0005dE-V1 for patch@linaro.org; Mon, 04 Sep 2017 08:59:16 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52928) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1doqSi-0005EK-UQ for qemu-devel@nongnu.org; Mon, 04 Sep 2017 08:26:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1doqSV-0004zY-IE for qemu-devel@nongnu.org; Mon, 04 Sep 2017 08:26:44 -0400 Received: from orth.archaic.org.uk ([2001:8b0:1d0::2]:37138) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1doqSV-0004yH-BZ for qemu-devel@nongnu.org; Mon, 04 Sep 2017 08:26:31 -0400 Received: from pm215 by orth.archaic.org.uk with local (Exim 4.89) (envelope-from ) id 1doqSU-0005dZ-Cf for qemu-devel@nongnu.org; Mon, 04 Sep 2017 13:26:30 +0100 From: Peter Maydell To: qemu-devel@nongnu.org Date: Mon, 4 Sep 2017 13:26:04 +0100 Message-Id: <1504527967-29248-34-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1504527967-29248-1-git-send-email-peter.maydell@linaro.org> References: <1504527967-29248-1-git-send-email-peter.maydell@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2001:8b0:1d0::2 Subject: [Qemu-devel] [PULL 33/36] hw/arm/aspeed_soc: Mark devices as user_creatable = false X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 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" From: Thomas Huth QEMU currently aborts if the user is accidentially trying to do something like this: $ aarch64-softmmu/qemu-system-aarch64 -S -M integratorcp -nographic QEMU 2.9.93 monitor - type 'help' for more information (qemu) device_add ast2400 Unexpected error in error_set_from_qdev_prop_error() at hw/core/qdev-properties.c:1032: Aborted (core dumped) The ast2400 SoC devices are clearly not creatable by the user since they are using the serial_hds and nd_table arrays directly in their realize function, so mark them with user_creatable = false. Signed-off-by: Thomas Huth Reviewed-by: Peter Maydell Reviewed-by: Cédric Le Goater Signed-off-by: Peter Maydell --- hw/arm/aspeed_soc.c | 2 ++ 1 file changed, 2 insertions(+) -- 2.7.4 diff --git a/hw/arm/aspeed_soc.c b/hw/arm/aspeed_soc.c index 22dcac9..13c6393 100644 --- a/hw/arm/aspeed_soc.c +++ b/hw/arm/aspeed_soc.c @@ -340,6 +340,8 @@ static void aspeed_soc_class_init(ObjectClass *oc, void *data) sc->info = (AspeedSoCInfo *) data; dc->realize = aspeed_soc_realize; + /* Reason: Uses serial_hds and nd_table in realize() directly */ + dc->user_creatable = false; } static const TypeInfo aspeed_soc_type_info = { From patchwork Mon Sep 4 12:26:05 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 111589 Delivered-To: patch@linaro.org Received: by 10.140.94.166 with SMTP id g35csp1489788qge; Mon, 4 Sep 2017 05:54:04 -0700 (PDT) X-Google-Smtp-Source: ADKCNb4Y4FlwXAGTKzb8XmqmorNELHcoYa4YqHdL3mAndV8zOHl0mOplh6zSxEw054D26aOUrCwW X-Received: by 10.55.109.66 with SMTP id i63mr590017qkc.19.1504529643982; Mon, 04 Sep 2017 05:54:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1504529643; cv=none; d=google.com; s=arc-20160816; b=OXNdF6vvwcI8uU9EHK1O3M7Z9AwHTMQoNP2QZMK07VOqeywIkhaZvy/tfuWsjODZjE Av6pd7p48vJF3+Fe1Jyezr/s7LlOmNgvSNuLObkaIZx2hRjpPEvix1L+5yO8ZejErzMI IHqY52VwNKt0yKyIlnohMAv+3LCytL/ZuCXCNMCQEdqqSjnDTYxb82UUUrxS0J1DR4yg lioeD809fewdcVO8H5Tcpxieraoz66k7d65bgZJ5REyWd+1zPbuVN8sbCt8VJZDJ4VqO RujBkkLQEuCjx1FVAzOI0H5WRwJ9qOhohPmJy5SeOSk9j3+kK4wjvKFh4pq0lHOastE/ M1hw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:arc-authentication-results; bh=RoDQBqw5K+H3NBvCTPKT5vKckS8JZ3mRy0wzvF56Ybk=; b=mdyF0oB/QQ5wpvRGM+5LIfSsQW5h5mm8x+6rxjRV4oMlGhD5b8pH4LzoS0pBVpUqe+ 3kg8ZVPnsmdy7TdbM/GzeOE6oY/NrTZwpW3AEQ99XqRH43Vc99c3erD8ipxwDh5mzJKC Q/MV68tW8uiQ0Yy0qtFXgLalAdh3GD0XIYHAmz4b561XtdtMMb7qUwc8OlLT2qLp99Iv 7KJ3WhlJ+0LqWNopCUnrKE8M/UqW4QAfRjZROFP6qse0QhT0TWH+ZHEjgt1CpJbPlI2a z5S0tbY/ZyCVPjk/xNlkjUmYxenFYs6/qbcXGaA63ObNCEzhACDQevMWHCWBkb9993CC rkmw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id b7si5495673qka.402.2017.09.04.05.54.03 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 04 Sep 2017 05:54:03 -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; Authentication-Results: mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:59674 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1doqt7-0001BM-RT for patch@linaro.org; Mon, 04 Sep 2017 08:54:01 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52936) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1doqSj-0005Eq-ES for qemu-devel@nongnu.org; Mon, 04 Sep 2017 08:26:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1doqSW-00050I-FN for qemu-devel@nongnu.org; Mon, 04 Sep 2017 08:26:45 -0400 Received: from orth.archaic.org.uk ([2001:8b0:1d0::2]:37138) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1doqSW-0004yH-9t for qemu-devel@nongnu.org; Mon, 04 Sep 2017 08:26:32 -0400 Received: from pm215 by orth.archaic.org.uk with local (Exim 4.89) (envelope-from ) id 1doqSV-0005dq-57 for qemu-devel@nongnu.org; Mon, 04 Sep 2017 13:26:31 +0100 From: Peter Maydell To: qemu-devel@nongnu.org Date: Mon, 4 Sep 2017 13:26:05 +0100 Message-Id: <1504527967-29248-35-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1504527967-29248-1-git-send-email-peter.maydell@linaro.org> References: <1504527967-29248-1-git-send-email-peter.maydell@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2001:8b0:1d0::2 Subject: [Qemu-devel] [PULL 34/36] hw/arm/digic: Mark device with user_creatable = false X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 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" From: Thomas Huth QEMU currently shows some unexpected behavior when the user trys to do a "device_add digic" on an unrelated ARM machine like integratorcp in "-nographic" mode (the device_add command does not immediately return to the monitor prompt), and trying to "device_del" the device later results in a "qemu/qdev-monitor.c:872:qdev_unplug: assertion failed: (hotplug_ctrl)" error condition. Looking at the realize function of the device, it uses serial_hds directly and this means that the device can not be added a second time, so let's simply mark it with "user_creatable = false" now. Signed-off-by: Thomas Huth Reviewed-by: Peter Maydell Signed-off-by: Peter Maydell --- hw/arm/digic.c | 2 ++ 1 file changed, 2 insertions(+) -- 2.7.4 diff --git a/hw/arm/digic.c b/hw/arm/digic.c index 94f3263..6184020 100644 --- a/hw/arm/digic.c +++ b/hw/arm/digic.c @@ -101,6 +101,8 @@ static void digic_class_init(ObjectClass *oc, void *data) DeviceClass *dc = DEVICE_CLASS(oc); dc->realize = digic_realize; + /* Reason: Uses serial_hds in the realize function --> not usable twice */ + dc->user_creatable = false; } static const TypeInfo digic_type_info = { From patchwork Mon Sep 4 12:26:06 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 111592 Delivered-To: patch@linaro.org Received: by 10.140.94.166 with SMTP id g35csp1496561qge; Mon, 4 Sep 2017 06:00:26 -0700 (PDT) X-Google-Smtp-Source: ADKCNb6Hh3NjlxrbQLdTxLtZGWmJz9yuR5Iw7x+NTrFzaf9uw93H/xafCWKZ/WjzXuVwDcZbS+s4 X-Received: by 10.55.79.85 with SMTP id d82mr632993qkb.5.1504530026018; Mon, 04 Sep 2017 06:00:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1504530026; cv=none; d=google.com; s=arc-20160816; b=SMLn/ijd6JoUXJbltF1gvAvgwMSwZHV4oTDziv4rI/70S4YtbkMGxM9fjAUOXk8voc GcdlA62rIyKMQMDd+joRsxwNuH6lUZV+VeKaIfMow3xCfWZ2cQ5PYyG6BXweKr3EuUz4 SLVHkJkr+e63HANhMfhYBTV+50nvigqF2qujvXUEQYvZ1Y6PtoT+72o90xX2fB0CTe3l SoMtj/JVV1wcWsFR9+YTl5o4Kw6GvBFkAYSXotybCaSLuma8ezT8yF1A3AvkanwHliBF 2a+kj9JAchb2dEtdyFlf4gzIuw5zb6fKjt9wHVWas9CCAPiE8SB4TXKLHWTgCA93LoK/ jLJQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:arc-authentication-results; bh=hYE5gaGANDpZMi1WipSoBxfe/OFT0wu4jjtjGKRvidI=; b=UCwnKKknVK/PSG50ub4QhAdXIoc0iz0lG+cdTlvA5qUp1GX2+Pc5MPcoMGZReYKb+n zGy+mRQN5Skh7zredhOsEsxK/1bH24oD9D8gBMLuF8HDZ4C7ErGHC0Ob/+oFBJ4LBBa+ iwEzKASlwXmkuSHfeDRM0m9q46UQMD6RIGL/lv4jHmObZ+5hPS8qvwiPaNBcJj/Ty4Yk byjGvz0pjmJXss5pjxjr6lvDl+A2PkJuoShZNRHMcWAnFjc6bEq8jLv42lIIb9K2PF3c JJMjmwGTPvLDdhb0Y/eSkL8yIRcBm7AkrzPqvYIwbd8rnYqIz+xRlZlLYjchsxprKkXy 6tvA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id l82si607179qki.405.2017.09.04.06.00.25 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 04 Sep 2017 06:00:25 -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; Authentication-Results: mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:60593 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1doqzH-0006wC-RR for patch@linaro.org; Mon, 04 Sep 2017 09:00:23 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52954) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1doqSk-0005Fo-8L for qemu-devel@nongnu.org; Mon, 04 Sep 2017 08:26:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1doqSX-00050p-0s for qemu-devel@nongnu.org; Mon, 04 Sep 2017 08:26:46 -0400 Received: from orth.archaic.org.uk ([2001:8b0:1d0::2]:37140) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1doqSW-000503-Qa for qemu-devel@nongnu.org; Mon, 04 Sep 2017 08:26:32 -0400 Received: from pm215 by orth.archaic.org.uk with local (Exim 4.89) (envelope-from ) id 1doqSV-0005eU-RS for qemu-devel@nongnu.org; Mon, 04 Sep 2017 13:26:31 +0100 From: Peter Maydell To: qemu-devel@nongnu.org Date: Mon, 4 Sep 2017 13:26:06 +0100 Message-Id: <1504527967-29248-36-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1504527967-29248-1-git-send-email-peter.maydell@linaro.org> References: <1504527967-29248-1-git-send-email-peter.maydell@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2001:8b0:1d0::2 Subject: [Qemu-devel] [PULL 35/36] target/arm: Fix aa64 ldp register writeback X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 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" From: Richard Henderson For "ldp x0, x1, [x0]", if the second load is on a second page and the second page is unmapped, the exception would be raised with x0 already modified. This means the instruction couldn't be restarted. Cc: qemu-arm@nongnu.org Cc: qemu-stable@nongnu.org Reported-by: Andrew Signed-off-by: Richard Henderson Message-id: 20170825224833.4463-1-richard.henderson@linaro.org Fixes: https://bugs.launchpad.net/qemu/+bug/1713066 Signed-off-by: Richard Henderson [PMM: tweaked comment format] Reviewed-by: Peter Maydell Signed-off-by: Peter Maydell --- target/arm/translate-a64.c | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) -- 2.7.4 diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c index 2200e25..cb44632 100644 --- a/target/arm/translate-a64.c +++ b/target/arm/translate-a64.c @@ -2217,29 +2217,34 @@ static void disas_ldst_pair(DisasContext *s, uint32_t insn) } else { do_fp_st(s, rt, tcg_addr, size); } - } else { - TCGv_i64 tcg_rt = cpu_reg(s, rt); - if (is_load) { - do_gpr_ld(s, tcg_rt, tcg_addr, size, is_signed, false, - false, 0, false, false); - } else { - do_gpr_st(s, tcg_rt, tcg_addr, size, - false, 0, false, false); - } - } - tcg_gen_addi_i64(tcg_addr, tcg_addr, 1 << size); - if (is_vector) { + tcg_gen_addi_i64(tcg_addr, tcg_addr, 1 << size); if (is_load) { do_fp_ld(s, rt2, tcg_addr, size); } else { do_fp_st(s, rt2, tcg_addr, size); } } else { + TCGv_i64 tcg_rt = cpu_reg(s, rt); TCGv_i64 tcg_rt2 = cpu_reg(s, rt2); + if (is_load) { + TCGv_i64 tmp = tcg_temp_new_i64(); + + /* Do not modify tcg_rt before recognizing any exception + * from the second load. + */ + do_gpr_ld(s, tmp, tcg_addr, size, is_signed, false, + false, 0, false, false); + tcg_gen_addi_i64(tcg_addr, tcg_addr, 1 << size); do_gpr_ld(s, tcg_rt2, tcg_addr, size, is_signed, false, false, 0, false, false); + + tcg_gen_mov_i64(tcg_rt, tmp); + tcg_temp_free_i64(tmp); } else { + do_gpr_st(s, tcg_rt, tcg_addr, size, + false, 0, false, false); + tcg_gen_addi_i64(tcg_addr, tcg_addr, 1 << size); do_gpr_st(s, tcg_rt2, tcg_addr, size, false, 0, false, false); } From patchwork Mon Sep 4 12:26:07 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 111588 Delivered-To: patch@linaro.org Received: by 10.140.94.166 with SMTP id g35csp1489030qge; Mon, 4 Sep 2017 05:53:18 -0700 (PDT) X-Google-Smtp-Source: ADKCNb5blVElzRiphUz4FaRXXiHIGti+EKsV6hFS+CLyQBNPkLnDAgIPuUg6VPA9rrW92iRfehnu X-Received: by 10.200.47.24 with SMTP id j24mr490160qta.147.1504529598880; Mon, 04 Sep 2017 05:53:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1504529598; cv=none; d=google.com; s=arc-20160816; b=s+g4435nAPO6y8ZtNyWfTZdqJ6eW9q6uNaDVR7/wRAGxzbcWPOWyiR9jYXnQxrUQkk cgoGYb1ocSTz32Mkcas4A3NoygxjNWmbSA8uBZecj4zKtibe6JFktK3aTr/BiM0CW3oI Urw7r+aaY9Nwo9llgU7QU96rKJmpnN/yvGfNciKtFzX3ARsAsFJd1GeI0MbNh4fOWmA3 veMwM9yAmvFTAduJfBzgYXeKP4bcFLX2x7yKSNhdxh0iWUwEVyc7vRRULGTptj2jOJpx n0+Qn+7h0cIVMebVw970fFNkkppAgM4IzFEMU0V1wT4Skbl6Ug5vRebsK0Iq0IHhk8uk cAmw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:arc-authentication-results; bh=GaYuq0t0E5bsw1L7cR3g/nYSEKyN1oljqW7YW88E7wU=; b=sRKzxMznc4Nl7HCekXy5gYx/T5C2JZowLRGmUstojUw5qUfE7l07qKhycI8h8ZnAS2 iR8vgN0EdsEuudJGUzukV+ke/bkD99Yd9wJi11Ca/Q84dNItfKH7kT+NDmlRaMXwIkMF 1w7RkpTQeUkwYkHVJLlWe3HKIVmofjewyzNGERkDUGhO7R/XTX2/tWLIET/chmIxUQkk BQwNKkGSxaC4kn4jACOy4FmjCTf1qUt+QgCDwrPRHZ4CNq6YTYJCIA+X+VAlIXAkWBwF A1xRSOU5Rk2tgKdn2WuelbLvxqHL5kPejdIHer5eUnVfl6rHZdismwFdG+3d3QOcGC56 ma0A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id j123si5297735qkd.381.2017.09.04.05.53.18 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 04 Sep 2017 05:53:18 -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; Authentication-Results: mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:59670 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1doqsO-0000MX-OK for patch@linaro.org; Mon, 04 Sep 2017 08:53:16 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52956) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1doqSk-0005Fs-Bx for qemu-devel@nongnu.org; Mon, 04 Sep 2017 08:26:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1doqSY-00052l-2m for qemu-devel@nongnu.org; Mon, 04 Sep 2017 08:26:46 -0400 Received: from orth.archaic.org.uk ([2001:8b0:1d0::2]:37140) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1doqSX-000503-PL for qemu-devel@nongnu.org; Mon, 04 Sep 2017 08:26:34 -0400 Received: from pm215 by orth.archaic.org.uk with local (Exim 4.89) (envelope-from ) id 1doqSW-0005ej-IT for qemu-devel@nongnu.org; Mon, 04 Sep 2017 13:26:32 +0100 From: Peter Maydell To: qemu-devel@nongnu.org Date: Mon, 4 Sep 2017 13:26:07 +0100 Message-Id: <1504527967-29248-37-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1504527967-29248-1-git-send-email-peter.maydell@linaro.org> References: <1504527967-29248-1-git-send-email-peter.maydell@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2001:8b0:1d0::2 Subject: [Qemu-devel] [PULL 36/36] arm_gicv3_kvm: Fix compile warning X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 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" From: Pranith Kumar Fix the following warning: /home/pranith/qemu/hw/intc/arm_gicv3_kvm.c:296:17: warning: logical not is only applied to the left hand side of this bitwise operator [-Wlogical-not-parentheses] if (!c->gicr_ctlr & GICR_CTLR_ENABLE_LPIS) { ^ ~ /home/pranith/qemu/hw/intc/arm_gicv3_kvm.c:296:17: note: add parentheses after the '!' to evaluate the bitwise operator first if (!c->gicr_ctlr & GICR_CTLR_ENABLE_LPIS) { ^ /home/pranith/qemu/hw/intc/arm_gicv3_kvm.c:296:17: note: add parentheses around left hand side expression to silence this warning if (!c->gicr_ctlr & GICR_CTLR_ENABLE_LPIS) { ^ This logic error meant we were not setting the PTZ bit when we should -- luckily as the comment suggests this wouldn't have had any effects beyond making GIC initialization take a little longer. Signed-off-by: Pranith Kumar Message-id: 20170829173226.7625-1-bobby.prani@gmail.com Cc: qemu-stable@nongnu.org Reviewed-by: Peter Maydell Signed-off-by: Peter Maydell --- hw/intc/arm_gicv3_kvm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.7.4 diff --git a/hw/intc/arm_gicv3_kvm.c b/hw/intc/arm_gicv3_kvm.c index 6051c77..481fe54 100644 --- a/hw/intc/arm_gicv3_kvm.c +++ b/hw/intc/arm_gicv3_kvm.c @@ -293,7 +293,7 @@ static void kvm_arm_gicv3_put(GICv3State *s) kvm_gicr_access(s, GICR_PROPBASER + 4, ncpu, ®h, true); reg64 = c->gicr_pendbaser; - if (!c->gicr_ctlr & GICR_CTLR_ENABLE_LPIS) { + if (!(c->gicr_ctlr & GICR_CTLR_ENABLE_LPIS)) { /* Setting PTZ is advised if LPIs are disabled, to reduce * GIC initialization time. */