From patchwork Thu Sep 7 13:27: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: 111916 Delivered-To: patch@linaro.org Received: by 10.140.94.239 with SMTP id g102csp93641qge; Thu, 7 Sep 2017 06:28:53 -0700 (PDT) X-Google-Smtp-Source: AOwi7QCiVjjnkGpLMrrv7qe4KNbRq9Nv7MWjHsRkEYCB0jzDAK++vgor6hZMrMyn7HxsAPCCSKNH X-Received: by 10.55.19.136 with SMTP id 8mr3666327qkt.144.1504790933493; Thu, 07 Sep 2017 06:28:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1504790933; cv=none; d=google.com; s=arc-20160816; b=TqbRiq9s6ssUwCjVztLwp/YD723RXWiiRCNnC7xm6nh5+l2fABYeXDizul7shBXNpf FCeXSX6ONsMnOnfWbn8zzpnzyYZ4no9chSPqhLweENCRUm7pEXIU7DH80orpuiEJj5/n Z7f408qreAY5rGJNQ8OPg01j9sFi/63EJj8IXSpvrtgh6x15YUHFMxo0gW10q0184bKN zVW5J63Icqt3sOX7AvLfsRUH4m296Madh/kiXenpwKJ/Lg7NQUWW3PI/30gtRt4zo1f4 uFe/2ZJmnKjksZ0x7yaA+3C18iUh9IjUyoD1v1e/ytlM3uAKDleY/X8Jm/YjbJKO2SMp 2lPQ== 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=7NcIqr3QmKafDV4Y5XJIihw1NqD7yCsy10KlCNg3W1g=; b=aBf3hS5gZVDhJDIDTsKJyP29EhVlvhcrAuLYvSNdN5FwLAqh/PESL1yrYLfkjzfWLV 43LKp3zZYprTs4ECXNfCwFgeWBocAS+3nOuo1PiAbf+sL+yOVIxi6l06CxSSGMizkdNo GLwzV0ZTS5NjLo0ZnnTjcBPC2AUAM7kUpSo1X67RCvqzHq0JtGot2rrxcUxUz0hcaPZ4 1EZfxs6dKLRCALyr0X3DI30alLaIPUbW0Rt8Gh2xUcRujLKkXclFswMeqg9nI8JU4bmJ vMpMftwz0tFsuIB+DxXjl5PjmN7IhxZXUh17KvOq7KhTLfXgLAu47NffGMlEQfqi6SqM PjNg== 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 30si2949538qtq.294.2017.09.07.06.28.52 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 07 Sep 2017 06: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]:40495 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dpwrT-000136-4T for patch@linaro.org; Thu, 07 Sep 2017 09:28:51 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56290) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dpwqw-0000zJ-H5 for qemu-devel@nongnu.org; Thu, 07 Sep 2017 09:28:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dpwqr-0007a0-T6 for qemu-devel@nongnu.org; Thu, 07 Sep 2017 09:28:18 -0400 Received: from orth.archaic.org.uk ([2001:8b0:1d0::2]:37186) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dpwqr-0007Xf-Lq for qemu-devel@nongnu.org; Thu, 07 Sep 2017 09:28:13 -0400 Received: from pm215 by orth.archaic.org.uk with local (Exim 4.89) (envelope-from ) id 1dpwqi-0001V6-HK for qemu-devel@nongnu.org; Thu, 07 Sep 2017 14:28:04 +0100 From: Peter Maydell To: qemu-devel@nongnu.org Date: Thu, 7 Sep 2017 14:27:54 +0100 Message-Id: <1504790904-17018-2-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1504790904-17018-1-git-send-email-peter.maydell@linaro.org> References: <1504790904-17018-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/31] armv7m: Convert bitband.source-memory to DEFINE_PROP_LINK 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: Fam Zheng Signed-off-by: Fam Zheng Reviewed-by: Philippe Mathieu-Daudé Message-id: 20170905131149.10669-2-famz@redhat.com Reviewed-by: Peter Maydell Signed-off-by: Peter Maydell --- hw/arm/armv7m.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) -- 2.7.4 diff --git a/hw/arm/armv7m.c b/hw/arm/armv7m.c index d2477e8..4c560dd 100644 --- a/hw/arm/armv7m.c +++ b/hw/arm/armv7m.c @@ -97,12 +97,6 @@ static void bitband_init(Object *obj) BitBandState *s = BITBAND(obj); SysBusDevice *dev = SYS_BUS_DEVICE(obj); - object_property_add_link(obj, "source-memory", - TYPE_MEMORY_REGION, - (Object **)&s->source_memory, - qdev_prop_allow_set_link_before_realize, - OBJ_PROP_LINK_UNREF_ON_RELEASE, - &error_abort); memory_region_init_io(&s->iomem, obj, &bitband_ops, s, "bitband", 0x02000000); sysbus_init_mmio(dev, &s->iomem); @@ -349,6 +343,8 @@ void armv7m_load_kernel(ARMCPU *cpu, const char *kernel_filename, int mem_size) static Property bitband_properties[] = { DEFINE_PROP_UINT32("base", BitBandState, base, 0), + DEFINE_PROP_LINK("source-memory", BitBandState, source_memory, + TYPE_MEMORY_REGION, MemoryRegion *), DEFINE_PROP_END_OF_LIST(), }; From patchwork Thu Sep 7 13:27: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: 111941 Delivered-To: patch@linaro.org Received: by 10.140.94.239 with SMTP id g102csp117738qge; Thu, 7 Sep 2017 06:47:41 -0700 (PDT) X-Google-Smtp-Source: AOwi7QBK5DyV5WGLU0ublml03qByv5C0+CcncuSBWZZ1CzSySCbi+2i7b8vWs40wQLlVT8HsVO4I X-Received: by 10.55.18.96 with SMTP id c93mr3821182qkh.297.1504792061586; Thu, 07 Sep 2017 06:47:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1504792061; cv=none; d=google.com; s=arc-20160816; b=HuzAYM8QbkMD2mU2/76wtCFFMQiFUM20dH+6NJrNl9f2pyjt9tx70HGRkLLXs6SCUM 5pF8wvo1hqMJx5wWjrynt8efVFHKhLCrhGa2srCzH01xrXGDN4dQNtlsc6iCEFfdR+GL yuz6//yRr5ZQIGicFa5iCTLUKw56MWuRe0MxcrP7ysUYceJ9NcQlj3vEF+T3X9EhDzW+ tIbbrM/WcSPKoq2f0w1Qigb/QQJ97ejEDqDQLsmuYjy1zcISpVsTcJcTwwjSKJ26GnCK 1R7MWper2yRn/CsbRCd9ElnEjuOxqtoHHzPYqYQ/jE9O+hsJj71/zwxzU70CinJawv+/ 12vw== 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=1+KuiclUgT7F3uKzW/KNxssuWPCVVGblwKRKrpp9y1M=; b=onPPowa8JMdtGIgOYk9wB/47EMEecX1fmbstd82MutjUSo7mKPvImC22/1xDlqmTdj jVzSRdT25DjQH2wewewOqwoMDY84Hsr6zLNB9pkr/n8Kg9zFYI6/yqirgekcmfoBl2nP fOXXJz+pqPptE5JrzioR7t+doL9eoXx5aTmJ0zS6u0ei7MIlmAe2FTVTho1QBOiTf+E7 lue9NUyQh1LVQYa0vLi0GOb3o10j7Y2kdj2DVOP0K+Jxh1RLWTn5YOFr2dCxYWGnGnp6 h76fLzEER9XLCkY7EbcC4N2LWdafXo7G8x8zlpjV9J3VMKVR2kbTe+t3fTN89YWciH5S yxRA== 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 w64si2838983qte.548.2017.09.07.06.47.41 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 07 Sep 2017 06:47:41 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; 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]:40567 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dpx9f-0000z3-HE for patch@linaro.org; Thu, 07 Sep 2017 09:47:39 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56567) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dpwr9-000141-Ck for qemu-devel@nongnu.org; Thu, 07 Sep 2017 09:28:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dpwqy-0007eZ-Kc for qemu-devel@nongnu.org; Thu, 07 Sep 2017 09:28:31 -0400 Received: from orth.archaic.org.uk ([2001:8b0:1d0::2]:37190) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dpwqy-0007ak-DM for qemu-devel@nongnu.org; Thu, 07 Sep 2017 09:28:20 -0400 Received: from pm215 by orth.archaic.org.uk with local (Exim 4.89) (envelope-from ) id 1dpwqj-0001VJ-5u for qemu-devel@nongnu.org; Thu, 07 Sep 2017 14:28:05 +0100 From: Peter Maydell To: qemu-devel@nongnu.org Date: Thu, 7 Sep 2017 14:27:55 +0100 Message-Id: <1504790904-17018-3-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1504790904-17018-1-git-send-email-peter.maydell@linaro.org> References: <1504790904-17018-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 02/31] armv7m: Convert armv7m.memory to DEFINE_PROP_LINK 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: Fam Zheng Signed-off-by: Fam Zheng Reviewed-by: Philippe Mathieu-Daudé Message-id: 20170905131149.10669-3-famz@redhat.com Reviewed-by: Peter Maydell Signed-off-by: Peter Maydell --- hw/arm/armv7m.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) -- 2.7.4 diff --git a/hw/arm/armv7m.c b/hw/arm/armv7m.c index 4c560dd..b64a409 100644 --- a/hw/arm/armv7m.c +++ b/hw/arm/armv7m.c @@ -132,12 +132,6 @@ static void armv7m_instance_init(Object *obj) /* Can't init the cpu here, we don't yet know which model to use */ - object_property_add_link(obj, "memory", - TYPE_MEMORY_REGION, - (Object **)&s->board_memory, - qdev_prop_allow_set_link_before_realize, - OBJ_PROP_LINK_UNREF_ON_RELEASE, - &error_abort); memory_region_init(&s->container, obj, "armv7m-container", UINT64_MAX); object_initialize(&s->nvic, sizeof(s->nvic), TYPE_NVIC); @@ -248,6 +242,8 @@ static void armv7m_realize(DeviceState *dev, Error **errp) static Property armv7m_properties[] = { DEFINE_PROP_STRING("cpu-model", ARMv7MState, cpu_model), + DEFINE_PROP_LINK("memory", ARMv7MState, board_memory, TYPE_MEMORY_REGION, + MemoryRegion *), DEFINE_PROP_END_OF_LIST(), }; From patchwork Thu Sep 7 13:27: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: 111942 Delivered-To: patch@linaro.org Received: by 10.140.94.239 with SMTP id g102csp117836qge; Thu, 7 Sep 2017 06:47:47 -0700 (PDT) X-Google-Smtp-Source: ADKCNb7myLNSDLmWFjk3IDAnS7vkuEKR1d7NXpcnvpJ2vEk9MfmpIRkCuqQMFnB2v0uy0gfRE+xF X-Received: by 10.200.57.83 with SMTP id t19mr4130196qtb.150.1504792067321; Thu, 07 Sep 2017 06:47:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1504792067; cv=none; d=google.com; s=arc-20160816; b=wRTTjLmwdVBer7U/3GM1EJWgkduT5tvR8RvJK0Vedqw1ITK7vZVwL8JXEHxeI1La/Z EoZJennItgmn719Sy4L0sCig+lN++YMaekStmDICto+KveeSr4CMCYAmf+fmlv/hGWyz 1oueL3M+e1I6qb3AS5QOxXjmUzhkcszdK3hStt1F/2DDm739O3FsLlxNNDEDc2zS1Wwx UKvySq+8wUXmn2hFQuvHy/pqK509OIJSVk+IEsYExVNdrqT/FRR5NjnD5sDh8/FhmEFY TSuqSoy4A+5ZVw+RrumwlEinn57+ImYVFKG5djV/52FR0C9iOADWBAcsdi4erJ3nGpnt VbFQ== 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=7XGGJXk+FfhVOdzYtctXDMLRlC5accfSkONRS1bcCaI=; b=oHzNtBtHFgxNkdF15RfISHzIV7r5YOpsMX+qD6+oAmgth+uil0UwxLon5S/GDZeoTu wfqziVPUrz47qktGUVWIIKZZ9/rrMYYQmdQ0kAn2P79jGAFERjf5osknQm1pNQ7m+BOU Lj4GLhTNDoJHUZjQnyp4a18sbCVUof06QwauwJSvubYFD+4E2/ZFoLF+8vgJPs0+lT1t HpRnOlVoiv5OfzN+FrMlEA4AWvOSyN/MO+jxz9E+avIbVyQPjH6Xx98kuTJnQ+BWd4MV gm3ilxN2Vx8vYBpwHoqRGJl6ZU1H3UcDxI3QjTrtGe8U96BmNXjFNRMI8abYRhBsShHp nT/A== 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 n132si2786790qka.521.2017.09.07.06.47.47 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 07 Sep 2017 06:47: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]:40566 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dpx9l-0000qf-6C for patch@linaro.org; Thu, 07 Sep 2017 09:47:45 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56439) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dpwr3-000103-2N for qemu-devel@nongnu.org; Thu, 07 Sep 2017 09:28:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dpwqx-0007dy-Ut for qemu-devel@nongnu.org; Thu, 07 Sep 2017 09:28:25 -0400 Received: from orth.archaic.org.uk ([2001:8b0:1d0::2]:37186) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dpwqx-0007Xf-Nv for qemu-devel@nongnu.org; Thu, 07 Sep 2017 09:28:19 -0400 Received: from pm215 by orth.archaic.org.uk with local (Exim 4.89) (envelope-from ) id 1dpwqj-0001VW-S5 for qemu-devel@nongnu.org; Thu, 07 Sep 2017 14:28:05 +0100 From: Peter Maydell To: qemu-devel@nongnu.org Date: Thu, 7 Sep 2017 14:27:56 +0100 Message-Id: <1504790904-17018-4-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1504790904-17018-1-git-send-email-peter.maydell@linaro.org> References: <1504790904-17018-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 03/31] gicv3: Convert to DEFINE_PROP_LINK 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: Fam Zheng Signed-off-by: Fam Zheng Message-id: 20170905131149.10669-4-famz@redhat.com Reviewed-by: Peter Maydell Signed-off-by: Peter Maydell --- hw/intc/arm_gicv3_its_kvm.c | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) -- 2.7.4 diff --git a/hw/intc/arm_gicv3_its_kvm.c b/hw/intc/arm_gicv3_its_kvm.c index 1f8991b..39903d5 100644 --- a/hw/intc/arm_gicv3_its_kvm.c +++ b/hw/intc/arm_gicv3_its_kvm.c @@ -120,17 +120,6 @@ static void kvm_arm_its_realize(DeviceState *dev, Error **errp) qemu_add_vm_change_state_handler(vm_change_state_handler, s); } -static void kvm_arm_its_init(Object *obj) -{ - GICv3ITSState *s = KVM_ARM_ITS(obj); - - object_property_add_link(obj, "parent-gicv3", - "kvm-arm-gicv3", (Object **)&s->gicv3, - object_property_allow_set_link, - OBJ_PROP_LINK_UNREF_ON_RELEASE, - &error_abort); -} - /** * kvm_arm_its_pre_save - handles the saving of ITS registers. * ITS tables are flushed into guest RAM separately and earlier, @@ -205,12 +194,19 @@ static void kvm_arm_its_post_load(GICv3ITSState *s) GITS_CTLR, &s->ctlr, true, &error_abort); } +static Property kvm_arm_its_props[] = { + DEFINE_PROP_LINK("parent-gicv3", GICv3ITSState, gicv3, "kvm-arm-gicv3", + GICv3State *), + DEFINE_PROP_END_OF_LIST(), +}; + static void kvm_arm_its_class_init(ObjectClass *klass, void *data) { DeviceClass *dc = DEVICE_CLASS(klass); GICv3ITSCommonClass *icc = ARM_GICV3_ITS_COMMON_CLASS(klass); dc->realize = kvm_arm_its_realize; + dc->props = kvm_arm_its_props; icc->send_msi = kvm_its_send_msi; icc->pre_save = kvm_arm_its_pre_save; icc->post_load = kvm_arm_its_post_load; @@ -220,7 +216,6 @@ static const TypeInfo kvm_arm_its_info = { .name = TYPE_KVM_ARM_ITS, .parent = TYPE_ARM_GICV3_ITS_COMMON, .instance_size = sizeof(GICv3ITSState), - .instance_init = kvm_arm_its_init, .class_init = kvm_arm_its_class_init, }; From patchwork Thu Sep 7 13:27:57 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 111933 Delivered-To: patch@linaro.org Received: by 10.140.94.239 with SMTP id g102csp108646qge; Thu, 7 Sep 2017 06:40:05 -0700 (PDT) X-Google-Smtp-Source: AOwi7QAlHrhqVrs4NheNv2mHeC5V/bhea3xGUKvk7/aEfH5yvBaTqRu+e9Y/dt5uWr1FK5AGtENZ X-Received: by 10.55.3.133 with SMTP id 127mr4012315qkd.42.1504791605264; Thu, 07 Sep 2017 06:40:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1504791605; cv=none; d=google.com; s=arc-20160816; b=edACEToQ4lTRHSc/2TehylbtXiSns+FZoNNFgflbGQEc4f9zQT28QX2p8VvgMkF8SZ ecr2mDu9GNuZSvbeSsvsKWcEqlPCUPecdYpaicUqz5YZpkKW4dh8Duy/7sdSG+m2Ba3+ fvdi0MIPTtIClQWKlu8C0HxZKNVssJbR12aBc+ZwsucIvjUK58zRRRP9vIkvKrC3zAsJ C98bUQkKsUBDMUSBRGme5Fx6u+OsppJAK9zE3met0FjNapFexAQP9IX3Quyt1ITtxYF7 Xe7njz1PAraY1RTlBGNFaUU96dKblaHw+M7m1Mv8pHWVY8HcXQXXYQG5KaF3lTIH5b6e Gvww== 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=Vh5mmvipkAUx4adfWZRPD2wMp0nmMWTrnIYxMfi62uo=; b=kdb3mADrqeTDzE4QWWoEp8xzEDBwwgoCN595hk5NYFAhSfed6DAcr3e4cWo8463JXS maclkADlel6OuKjgnx5Y6B59gdMUmo2kcrBPoGq0XNU6Qeh7tu01XNTuq8JYhld8FqTF B5MhnpROi4S6fURQx6UjP6jeaMpYaLWWbAnHRYGzcZg9nRl7szERgxHnaKX7jWoJrDf0 7TmS/guIs7/Ig0ivdDo4gXnE4lgPtwT5+2+SD/dS8ZT/rGO04lhCv0hM2E+XAAbI77ib j/7rxE0TvdEhEoyNGMBdGyplLdXU/pkeDi/7UohuQFz3qT8sa8TTnci1x9WZVNJZL2vf yq3A== 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 h64si2677736qkf.505.2017.09.07.06.40.04 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 07 Sep 2017 06:40: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]:40534 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dpx2J-0002IM-6h for patch@linaro.org; Thu, 07 Sep 2017 09:40:03 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56428) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dpwr2-0000zy-My for qemu-devel@nongnu.org; Thu, 07 Sep 2017 09:28:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dpwqx-0007ds-Te for qemu-devel@nongnu.org; Thu, 07 Sep 2017 09:28:24 -0400 Received: from orth.archaic.org.uk ([2001:8b0:1d0::2]:37192) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dpwqx-0007bf-NK for qemu-devel@nongnu.org; Thu, 07 Sep 2017 09:28:19 -0400 Received: from pm215 by orth.archaic.org.uk with local (Exim 4.89) (envelope-from ) id 1dpwqk-0001Vn-K6 for qemu-devel@nongnu.org; Thu, 07 Sep 2017 14:28:06 +0100 From: Peter Maydell To: qemu-devel@nongnu.org Date: Thu, 7 Sep 2017 14:27:57 +0100 Message-Id: <1504790904-17018-5-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1504790904-17018-1-git-send-email-peter.maydell@linaro.org> References: <1504790904-17018-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 04/31] xlnx_zynqmp: Convert to DEFINE_PROP_LINK 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: Fam Zheng Signed-off-by: Fam Zheng Reviewed-by: Philippe Mathieu-Daudé Message-id: 20170905131149.10669-5-famz@redhat.com Reviewed-by: Peter Maydell Signed-off-by: Peter Maydell --- hw/arm/xlnx-zynqmp.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) -- 2.7.4 diff --git a/hw/arm/xlnx-zynqmp.c b/hw/arm/xlnx-zynqmp.c index 9eceadb..22c2a33 100644 --- a/hw/arm/xlnx-zynqmp.c +++ b/hw/arm/xlnx-zynqmp.c @@ -140,11 +140,6 @@ static void xlnx_zynqmp_init(Object *obj) &error_abort); } - object_property_add_link(obj, "ddr-ram", TYPE_MEMORY_REGION, - (Object **)&s->ddr_ram, - qdev_prop_allow_set_link_before_realize, - OBJ_PROP_LINK_UNREF_ON_RELEASE, &error_abort); - object_initialize(&s->gic, sizeof(s->gic), gic_class_name()); qdev_set_parent_bus(DEVICE(&s->gic), sysbus_get_default()); @@ -433,6 +428,8 @@ static Property xlnx_zynqmp_props[] = { DEFINE_PROP_STRING("boot-cpu", XlnxZynqMPState, boot_cpu), DEFINE_PROP_BOOL("secure", XlnxZynqMPState, secure, false), DEFINE_PROP_BOOL("has_rpu", XlnxZynqMPState, has_rpu, false), + DEFINE_PROP_LINK("ddr-ram", XlnxZynqMPState, ddr_ram, TYPE_MEMORY_REGION, + MemoryRegion *), DEFINE_PROP_END_OF_LIST() }; From patchwork Thu Sep 7 13:27:58 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 111934 Delivered-To: patch@linaro.org Received: by 10.140.94.239 with SMTP id g102csp110505qge; Thu, 7 Sep 2017 06:41:38 -0700 (PDT) X-Google-Smtp-Source: AOwi7QCuxUJ9inPZIraTC31t9oMCvNscrahmlSc8y6TwZq1VLB5O6KdBwrduyo60QsgjBW8yyQb1 X-Received: by 10.200.41.240 with SMTP id 45mr3823087qtt.284.1504791698205; Thu, 07 Sep 2017 06:41:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1504791698; cv=none; d=google.com; s=arc-20160816; b=O74iOiO6dFkCls28jVcA01V3w+lv/P+PBQtOzJhVcyZ29FbxtexEcJLaKmH/Al8CTl hwd7XPZYD/9SVC4zZAzWVzbRGVDPv5+NzJH4xlG5wwa3pY+Fkd7mfVD/BDM6Pd+cKWI+ 1GVFWr8vfV9qUc6ZDDeCITtw/sHzRess89ZWZ61pJGcnTyhDALCXAZ5FBpAhiOlK2ke8 9QTai7n1YyKP4r4p8z8bajAAG0GzoZK9JQxwCa6VuQNRXk79SmX7aJaRn0msiLw8PQUn c8iom3NqbSPqCQhMjXJqVa8mvC2wQlQIi5R0VSFv6K0ow65RbHF68iys33AJMAKLDgSg a1XQ== 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=TYKUrJCuwFNGrn4K8OdTdFp54V8n7ez1nNch4ItO0go=; b=bulUcTRN0FBZgd4LY2xoyS6gltYRdNTun3jWRDUyWd281nA9milIZawylq8lyLs10b OMq2eH+LSPTywKK5yi7ChNup58h3qAQpVzpvhzgcnK72dbNkU8yT9MclH2TI+jVwcqvh HdDGGxXpQcWo2/xu5m5c+SN7Ed7xChFriHrxNQeRekMYUdZRmoKAqAQoXlHFHw769NoU 2NJRh5EgLWpinkSlxcTIMFC9ea38n6Zd4M66CCKDhowwjVF3lrDmoFYAe+TB+BobdhT2 a84AtzKW8qyU864hywuyfBdxrf6uUHKXr6wUWJuPfq+8knJBt+LC9ANevGHQM/AjDdWG ilew== 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 e65si2634963qkc.525.2017.09.07.06.41.37 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 07 Sep 2017 06:41:38 -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]:40541 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dpx3n-0003XK-Q4 for patch@linaro.org; Thu, 07 Sep 2017 09:41:35 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56514) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dpwr7-00012L-F8 for qemu-devel@nongnu.org; Thu, 07 Sep 2017 09:28:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dpwqx-0007df-M2 for qemu-devel@nongnu.org; Thu, 07 Sep 2017 09:28:29 -0400 Received: from orth.archaic.org.uk ([2001:8b0:1d0::2]:37190) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dpwqx-0007ak-CN for qemu-devel@nongnu.org; Thu, 07 Sep 2017 09:28:19 -0400 Received: from pm215 by orth.archaic.org.uk with local (Exim 4.89) (envelope-from ) id 1dpwql-0001X6-8v for qemu-devel@nongnu.org; Thu, 07 Sep 2017 14:28:07 +0100 From: Peter Maydell To: qemu-devel@nongnu.org Date: Thu, 7 Sep 2017 14:27:58 +0100 Message-Id: <1504790904-17018-6-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1504790904-17018-1-git-send-email-peter.maydell@linaro.org> References: <1504790904-17018-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 05/31] xilinx_axienet: Convert to DEFINE_PROP_LINK 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: Fam Zheng Signed-off-by: Fam Zheng Reviewed-by: Philippe Mathieu-Daudé Message-id: 20170905131149.10669-6-famz@redhat.com Reviewed-by: Peter Maydell Signed-off-by: Peter Maydell --- hw/net/xilinx_axienet.c | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) -- 2.7.4 diff --git a/hw/net/xilinx_axienet.c b/hw/net/xilinx_axienet.c index 5ffa739..d4c2c89 100644 --- a/hw/net/xilinx_axienet.c +++ b/hw/net/xilinx_axienet.c @@ -989,18 +989,6 @@ static void xilinx_enet_init(Object *obj) XilinxAXIEnet *s = XILINX_AXI_ENET(obj); SysBusDevice *sbd = SYS_BUS_DEVICE(obj); - object_property_add_link(obj, "axistream-connected", TYPE_STREAM_SLAVE, - (Object **) &s->tx_data_dev, - qdev_prop_allow_set_link_before_realize, - OBJ_PROP_LINK_UNREF_ON_RELEASE, - &error_abort); - object_property_add_link(obj, "axistream-control-connected", - TYPE_STREAM_SLAVE, - (Object **) &s->tx_control_dev, - qdev_prop_allow_set_link_before_realize, - OBJ_PROP_LINK_UNREF_ON_RELEASE, - &error_abort); - object_initialize(&s->rx_data_dev, sizeof(s->rx_data_dev), TYPE_XILINX_AXI_ENET_DATA_STREAM); object_initialize(&s->rx_control_dev, sizeof(s->rx_control_dev), @@ -1021,6 +1009,10 @@ static Property xilinx_enet_properties[] = { DEFINE_PROP_UINT32("rxmem", XilinxAXIEnet, c_rxmem, 0x1000), DEFINE_PROP_UINT32("txmem", XilinxAXIEnet, c_txmem, 0x1000), DEFINE_NIC_PROPERTIES(XilinxAXIEnet, conf), + DEFINE_PROP_LINK("axistream-connected", XilinxAXIEnet, + tx_data_dev, TYPE_STREAM_SLAVE, StreamSlave *), + DEFINE_PROP_LINK("axistream-control-connected", XilinxAXIEnet, + tx_control_dev, TYPE_STREAM_SLAVE, StreamSlave *), DEFINE_PROP_END_OF_LIST(), }; From patchwork Thu Sep 7 13:27:59 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 111920 Delivered-To: patch@linaro.org Received: by 10.140.94.239 with SMTP id g102csp97537qge; Thu, 7 Sep 2017 06:31:45 -0700 (PDT) X-Google-Smtp-Source: ADKCNb48IG2HtApd7P7eBw263D2d6fZjJxoWke/Wrlwh0Q/kwQ5f9CDR78liMbCf1kIVqGmm/VNt X-Received: by 10.237.33.102 with SMTP id 93mr4003659qtc.267.1504791105095; Thu, 07 Sep 2017 06:31:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1504791105; cv=none; d=google.com; s=arc-20160816; b=lijFpCFwfD7x/qtYo0RbTzm9cCvAErGJhSm3PzHLAkF81F97ZdSGtwAg2fO1hGRDH9 R4oJZm9Ye0xrSDQ183+1pGv2abET1W3R/B1bL26SBoKDqo1hftLf3ySy0orOD8ufbt02 UsXE9d/3sfQzjhiRVTkmxeC44mJMphfslyPhoQc+xRLoiBL3mXethVm6wwM/aPK6ByfU ibEXMOGVPg5lGY39eyDDV34muSuUgnhUC0FGt+IE4L3vwih050oAqfaEGmGwSxaVCeZ9 gpOFaqu22ej2l7r0zu/DPfXA/wuPcZQ6v0hOCUy47sAwjEUizD4q4Vd2FhISPmQ6OxXL XImw== 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=ajbv6dEBjaFx9NA1kJvHqbTi1v117Rq6H8TZxUdTmhY=; b=DumEZEsZXLFpkTMNSIk/jMSfyMyzJfpGusPvToqXfJM/jSbcGYR6A/ws8Tw5IsLX/6 JyCeKv0PNSZPwMxOPbIjXrOOqDdZN4vU08UWw6GhBAVrW/CadkOTekG+AR4HZ87Ud1PA V6Nl2BoQNyGkbmE09XhyynNXsKLe8p2ilgQnwvATflc/rJqbEhesVrf7O85Bbk/fl88q noGUqlOlW9WBsimuKFJgxG7bQec/EMrgY2/C0QiXAVCFHf0yDwFqhntq7rlchndU/2mA V2cLG2qu38n/P0sXU0BwhN/BWCTtx/ZMyFjz1lt1Ar8wbKDsV8b0IDL99hz0xFk3rRrR YboA== 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 i123si2763363qkd.128.2017.09.07.06.31.44 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 07 Sep 2017 06:31: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]:40508 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dpwuF-0003WJ-01 for patch@linaro.org; Thu, 07 Sep 2017 09:31:43 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56501) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dpwr7-00011u-2d for qemu-devel@nongnu.org; Thu, 07 Sep 2017 09:28:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dpwqx-0007dK-3Q for qemu-devel@nongnu.org; Thu, 07 Sep 2017 09:28:29 -0400 Received: from orth.archaic.org.uk ([2001:8b0:1d0::2]:37188) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dpwqw-0007a4-T0 for qemu-devel@nongnu.org; Thu, 07 Sep 2017 09:28:19 -0400 Received: from pm215 by orth.archaic.org.uk with local (Exim 4.89) (envelope-from ) id 1dpwql-0001XX-UI for qemu-devel@nongnu.org; Thu, 07 Sep 2017 14:28:07 +0100 From: Peter Maydell To: qemu-devel@nongnu.org Date: Thu, 7 Sep 2017 14:27:59 +0100 Message-Id: <1504790904-17018-7-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1504790904-17018-1-git-send-email-peter.maydell@linaro.org> References: <1504790904-17018-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 06/31] xilinx_axidma: Convert to DEFINE_PROP_LINK 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: Fam Zheng Signed-off-by: Fam Zheng Reviewed-by: Philippe Mathieu-Daudé Message-id: 20170905131149.10669-7-famz@redhat.com Reviewed-by: Peter Maydell Signed-off-by: Peter Maydell --- hw/dma/xilinx_axidma.c | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) -- 2.7.4 diff --git a/hw/dma/xilinx_axidma.c b/hw/dma/xilinx_axidma.c index 3987b5f..9b48103 100644 --- a/hw/dma/xilinx_axidma.c +++ b/hw/dma/xilinx_axidma.c @@ -562,18 +562,6 @@ static void xilinx_axidma_init(Object *obj) XilinxAXIDMA *s = XILINX_AXI_DMA(obj); SysBusDevice *sbd = SYS_BUS_DEVICE(obj); - object_property_add_link(obj, "axistream-connected", TYPE_STREAM_SLAVE, - (Object **)&s->tx_data_dev, - qdev_prop_allow_set_link_before_realize, - OBJ_PROP_LINK_UNREF_ON_RELEASE, - &error_abort); - object_property_add_link(obj, "axistream-control-connected", - TYPE_STREAM_SLAVE, - (Object **)&s->tx_control_dev, - qdev_prop_allow_set_link_before_realize, - OBJ_PROP_LINK_UNREF_ON_RELEASE, - &error_abort); - object_initialize(&s->rx_data_dev, sizeof(s->rx_data_dev), TYPE_XILINX_AXI_DMA_DATA_STREAM); object_initialize(&s->rx_control_dev, sizeof(s->rx_control_dev), @@ -593,6 +581,10 @@ static void xilinx_axidma_init(Object *obj) static Property axidma_properties[] = { DEFINE_PROP_UINT32("freqhz", XilinxAXIDMA, freqhz, 50000000), + DEFINE_PROP_LINK("axistream-connected", XilinxAXIDMA, + tx_data_dev, TYPE_STREAM_SLAVE, StreamSlave *), + DEFINE_PROP_LINK("axistream-control-connected", XilinxAXIDMA, + tx_control_dev, TYPE_STREAM_SLAVE, StreamSlave *), DEFINE_PROP_END_OF_LIST(), }; From patchwork Thu Sep 7 13:28: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: 111931 Delivered-To: patch@linaro.org Received: by 10.140.94.239 with SMTP id g102csp107298qge; Thu, 7 Sep 2017 06:39:02 -0700 (PDT) X-Google-Smtp-Source: ADKCNb4gtVOgE+lupCgaDqPw3AaAVSPXaI+RCOBxGnBZzPuTZRFGfGpyevP3PbshoW2g/cRLDFS9 X-Received: by 10.55.73.213 with SMTP id w204mr3783482qka.215.1504791542104; Thu, 07 Sep 2017 06:39:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1504791542; cv=none; d=google.com; s=arc-20160816; b=RQsG27BD5ToP5s5ZLI3A9isCKN5epLbA/g900hCZH+o5wBXZ3fsbg3CjMRkFhyIAey fO11gBG6+xd9I/cP7eE3c8bZ2SDPr+DB+nj2COHH/fPZTNgyJHgSW3wYgCcic/RBkbdN vizBcFHmzg/PUsQf1nxZysS1osh6nRx5aiyv7cZaa7xiqIhGjwBgFac3IOlouF1YIQYe m2HzEJf3XDwvo6C8mw0hwD1/HN1OyEusEB/eOSE6moUpfLOPOO77Du/Ooh5mFM6g5qPk jICLMkGJQHwVlDW6Cv6EdL0fKkrOq/y39zOH9klOWYpuvBsMc7aDWqG+n2pXInJWU9Vr ApOA== 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=e4+lRZpgJojldjCPSJhv3JonrvZ4Ri7inaYXPLW21eM=; b=RT61dyCAc3byxmiBh1XF/NILKiTzTDOj11I7r+mraLbZwc+7Qu0VOwTBP2zx+OZ1UJ 9OhbWAIty0M86Cg4a2kej8qtgmRexRiKVCSXYoGeAjNaN07Iwq5cxLv7fSWoAJbBZGFp GQDOxq4w6HRwkeb5s47SaFW53BrFcp5twBjxcvhurVSP/M9Yhcdt6h5lnZHN3GCVoxkU fTiQneJKF/0zG52c8nbbJ+GI/6+GliOITLF1iV67Hr5hX53RMcEwpka5tybTP6v2rZ4T 4UTlaz41pZlWmRi/rGyTk1VmK/knu++2WVFUKf46mw7SWSOotAAxnodehYgkG5rVk6NL stag== 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 l4si2746934qth.53.2017.09.07.06.39.01 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 07 Sep 2017 06:39:02 -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]:40532 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dpx1I-0001Q2-00 for patch@linaro.org; Thu, 07 Sep 2017 09:39:00 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56411) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dpwr2-0000zn-4N for qemu-devel@nongnu.org; Thu, 07 Sep 2017 09:28:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dpwqw-0007d8-VM for qemu-devel@nongnu.org; Thu, 07 Sep 2017 09:28:24 -0400 Received: from orth.archaic.org.uk ([2001:8b0:1d0::2]:37186) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dpwqw-0007Xf-MX for qemu-devel@nongnu.org; Thu, 07 Sep 2017 09:28:18 -0400 Received: from pm215 by orth.archaic.org.uk with local (Exim 4.89) (envelope-from ) id 1dpwqm-0001Xz-Jf for qemu-devel@nongnu.org; Thu, 07 Sep 2017 14:28:08 +0100 From: Peter Maydell To: qemu-devel@nongnu.org Date: Thu, 7 Sep 2017 14:28:00 +0100 Message-Id: <1504790904-17018-8-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1504790904-17018-1-git-send-email-peter.maydell@linaro.org> References: <1504790904-17018-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/31] hw/arm/allwinner-a10: Mark the allwinner-a10 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 exits unexpectedly when the user accidentially tries 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 allwinner-a10 Unsupported NIC model: smc91c111 Exiting just due to a "device_add" should not happen. Looking closer at the the realize and instance_init function of this device also reveals that it is using serial_hds and nd_table directly there, so this device is clearly not creatable by the user and should be marked accordingly. Signed-off-by: Thomas Huth Reviewed-by: Eduardo Habkost Message-id: 1503416789-32080-1-git-send-email-thuth@redhat.com Reviewed-by: Peter Maydell Signed-off-by: Peter Maydell --- hw/arm/allwinner-a10.c | 2 ++ scripts/device-crash-test | 1 - 2 files changed, 2 insertions(+), 1 deletion(-) -- 2.7.4 diff --git a/hw/arm/allwinner-a10.c b/hw/arm/allwinner-a10.c index f62a9a3..43a3f01 100644 --- a/hw/arm/allwinner-a10.c +++ b/hw/arm/allwinner-a10.c @@ -118,6 +118,8 @@ static void aw_a10_class_init(ObjectClass *oc, void *data) DeviceClass *dc = DEVICE_CLASS(oc); dc->realize = aw_a10_realize; + /* Reason: Uses serial_hds in realize and nd_table in instance_init */ + dc->user_creatable = false; } static const TypeInfo aw_a10_type_info = { diff --git a/scripts/device-crash-test b/scripts/device-crash-test index e77b693..81d65b9 100755 --- a/scripts/device-crash-test +++ b/scripts/device-crash-test @@ -187,7 +187,6 @@ ERROR_WHITELIST = [ {'log':r"Device [\w.,-]+ can not be dynamically instantiated"}, {'log':r"Platform Bus: Can not fit MMIO region of size "}, # other more specific errors we will ignore: - {'device':'allwinner-a10', 'log':"Unsupported NIC model:"}, {'device':'.*-spapr-cpu-core', 'log':r"CPU core type should be"}, {'log':r"MSI(-X)? is not supported by interrupt controller"}, {'log':r"pxb-pcie? devices cannot reside on a PCIe? bus"}, From patchwork Thu Sep 7 13:28: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: 111930 Delivered-To: patch@linaro.org Received: by 10.140.94.239 with SMTP id g102csp107136qge; Thu, 7 Sep 2017 06:38:56 -0700 (PDT) X-Google-Smtp-Source: AOwi7QB2BwWoSYn0g5GTfRecPRYLO0nT0AqQW6knFVIa9EMNRyDMwnimM5WQAX4wdYuqCPbQFivI X-Received: by 10.233.237.7 with SMTP id c7mr3614017qkg.69.1504791536391; Thu, 07 Sep 2017 06:38:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1504791536; cv=none; d=google.com; s=arc-20160816; b=MWdMkf79Wadsbabu2nQC9Vj/PMuFR3LQ2pjrSxI8uUK6AHhY1C2p3S347sYutY1LeL IKkRa8xRgf3X2oea/6PY9UIs477bBcc/rXHWH/aVAZ8YGRbz+zbk7/gH6LNsg8wJwdn0 zjVbuvEO4e3F+vpZFqLQFCImHVZ3lJgXezWAq74eeaSqqgT5Sbhnf97arArmEzh9Mipp wrM4ORtR62Fr3GStySIncoxh9WE3WaoFeBLXScIeWizb5m1cyLlKhUSBnlUG9SBq/zQ8 hIr1XvAxRpKfVujASioYKxTVYDsPaKjmiTAfHcPL1xdpOEahEWAQMnr7Ric92rlVAfq1 VbCw== 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=b7wYQmVx98E7xiFqYwNDTw2GD+rqPwNl5MPJjJubjoM=; b=w9RIizHO3CuLfXtQ4IHOOLo6JuLmwrhZCa10Gg2325dLtZKV42ZEMtTFcweuVdhDOS 6AtYUxaWyxVsG7nKwl+qj+KOWXEyNjVgSOpWTrIDAZRjpeoBthEQOh5RN9TNTA57sKx2 2sfZ8L1LU9OPzV1Jdo7UDYlCnGoOtJuYumt0ghC5oZuGIkzXX0JXC/sJEP5gzKdYjrfh 91gtKL+bwdFH8C7JxKhM90IlOELVTXBRE/74T3qXiuCJ6Aoo30tZR7ah7TNeqeU64po4 nRlU56NLhojNWqenpFC1LG6JsMTxGgoXZSWyOYjewgnR22NxurUu0UTSA2Nay1NlXtgr SjAA== 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 i127si2828737qkf.450.2017.09.07.06.38.55 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 07 Sep 2017 06:38: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]:40531 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dpx1C-0001Jz-3O for patch@linaro.org; Thu, 07 Sep 2017 09:38:54 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56430) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dpwr2-0000zz-NN for qemu-devel@nongnu.org; Thu, 07 Sep 2017 09:28:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dpwqw-0007cg-GX for qemu-devel@nongnu.org; Thu, 07 Sep 2017 09:28:24 -0400 Received: from orth.archaic.org.uk ([2001:8b0:1d0::2]:37190) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dpwqw-0007ak-6B for qemu-devel@nongnu.org; Thu, 07 Sep 2017 09:28:18 -0400 Received: from pm215 by orth.archaic.org.uk with local (Exim 4.89) (envelope-from ) id 1dpwqn-0001YR-9V for qemu-devel@nongnu.org; Thu, 07 Sep 2017 14:28:09 +0100 From: Peter Maydell To: qemu-devel@nongnu.org Date: Thu, 7 Sep 2017 14:28:01 +0100 Message-Id: <1504790904-17018-9-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1504790904-17018-1-git-send-email-peter.maydell@linaro.org> References: <1504790904-17018-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/31] target/arm: Implement ARMv8M's PMSAv8 registers 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" As part of ARMv8M, we need to add support for the PMSAv8 MPU architecture. PMSAv8 differs from PMSAv7 both in register/data layout (for instance using base and limit registers rather than base and size) and also in behaviour (for example it does not have subregions); rather than trying to wedge it into the existing PMSAv7 code and data structures, we define separate ones. This commit adds the data structures which hold the state for a PMSAv8 MPU and the register interface to it. The implementation of the MPU behaviour will be added in a subsequent commit. Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson Message-id: 1503414539-28762-2-git-send-email-peter.maydell@linaro.org --- target/arm/cpu.h | 13 ++++++ hw/intc/armv7m_nvic.c | 122 ++++++++++++++++++++++++++++++++++++++++++++++---- target/arm/cpu.c | 36 ++++++++++----- target/arm/machine.c | 29 +++++++++++- 4 files changed, 180 insertions(+), 20 deletions(-) -- 2.7.4 diff --git a/target/arm/cpu.h b/target/arm/cpu.h index 92771d3..9fd5de7 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -522,6 +522,19 @@ typedef struct CPUARMState { uint32_t rnr; } pmsav7; + /* PMSAv8 MPU */ + struct { + /* The PMSAv8 implementation also shares some PMSAv7 config + * and state: + * pmsav7.rnr (region number register) + * pmsav7_dregion (number of configured regions) + */ + uint32_t *rbar; + uint32_t *rlar; + uint32_t mair0; + uint32_t mair1; + } pmsav8; + void *nvic; const struct arm_boot_info *boot_info; /* Store GICv3CPUState to access from this struct */ diff --git a/hw/intc/armv7m_nvic.c b/hw/intc/armv7m_nvic.c index bbfe2d5..c0dbbad 100644 --- a/hw/intc/armv7m_nvic.c +++ b/hw/intc/armv7m_nvic.c @@ -544,25 +544,67 @@ static uint32_t nvic_readl(NVICState *s, uint32_t offset) { int region = cpu->env.pmsav7.rnr; + if (arm_feature(&cpu->env, ARM_FEATURE_V8)) { + /* PMSAv8M handling of the aliases is different from v7M: + * aliases A1, A2, A3 override the low two bits of the region + * number in MPU_RNR, and there is no 'region' field in the + * RBAR register. + */ + int aliasno = (offset - 0xd9c) / 8; /* 0..3 */ + if (aliasno) { + region = deposit32(region, 0, 2, aliasno); + } + if (region >= cpu->pmsav7_dregion) { + return 0; + } + return cpu->env.pmsav8.rbar[region]; + } + if (region >= cpu->pmsav7_dregion) { return 0; } return (cpu->env.pmsav7.drbar[region] & 0x1f) | (region & 0xf); } - case 0xda0: /* MPU_RASR */ - case 0xda8: /* MPU_RASR_A1 */ - case 0xdb0: /* MPU_RASR_A2 */ - case 0xdb8: /* MPU_RASR_A3 */ + case 0xda0: /* MPU_RASR (v7M), MPU_RLAR (v8M) */ + case 0xda8: /* MPU_RASR_A1 (v7M), MPU_RLAR_A1 (v8M) */ + case 0xdb0: /* MPU_RASR_A2 (v7M), MPU_RLAR_A2 (v8M) */ + case 0xdb8: /* MPU_RASR_A3 (v7M), MPU_RLAR_A3 (v8M) */ { int region = cpu->env.pmsav7.rnr; + if (arm_feature(&cpu->env, ARM_FEATURE_V8)) { + /* PMSAv8M handling of the aliases is different from v7M: + * aliases A1, A2, A3 override the low two bits of the region + * number in MPU_RNR. + */ + int aliasno = (offset - 0xda0) / 8; /* 0..3 */ + if (aliasno) { + region = deposit32(region, 0, 2, aliasno); + } + if (region >= cpu->pmsav7_dregion) { + return 0; + } + return cpu->env.pmsav8.rlar[region]; + } + if (region >= cpu->pmsav7_dregion) { return 0; } return ((cpu->env.pmsav7.dracr[region] & 0xffff) << 16) | (cpu->env.pmsav7.drsr[region] & 0xffff); } + case 0xdc0: /* MPU_MAIR0 */ + if (!arm_feature(&cpu->env, ARM_FEATURE_V8)) { + goto bad_offset; + } + return cpu->env.pmsav8.mair0; + case 0xdc4: /* MPU_MAIR1 */ + if (!arm_feature(&cpu->env, ARM_FEATURE_V8)) { + goto bad_offset; + } + return cpu->env.pmsav8.mair1; default: + bad_offset: qemu_log_mask(LOG_GUEST_ERROR, "NVIC: Bad read offset 0x%x\n", offset); return 0; } @@ -691,6 +733,26 @@ static void nvic_writel(NVICState *s, uint32_t offset, uint32_t value) { int region; + if (arm_feature(&cpu->env, ARM_FEATURE_V8)) { + /* PMSAv8M handling of the aliases is different from v7M: + * aliases A1, A2, A3 override the low two bits of the region + * number in MPU_RNR, and there is no 'region' field in the + * RBAR register. + */ + int aliasno = (offset - 0xd9c) / 8; /* 0..3 */ + + region = cpu->env.pmsav7.rnr; + if (aliasno) { + region = deposit32(region, 0, 2, aliasno); + } + if (region >= cpu->pmsav7_dregion) { + return; + } + cpu->env.pmsav8.rbar[region] = value; + tlb_flush(CPU(cpu)); + return; + } + if (value & (1 << 4)) { /* VALID bit means use the region number specified in this * value and also update MPU_RNR.REGION with that value. @@ -715,13 +777,32 @@ static void nvic_writel(NVICState *s, uint32_t offset, uint32_t value) tlb_flush(CPU(cpu)); break; } - case 0xda0: /* MPU_RASR */ - case 0xda8: /* MPU_RASR_A1 */ - case 0xdb0: /* MPU_RASR_A2 */ - case 0xdb8: /* MPU_RASR_A3 */ + case 0xda0: /* MPU_RASR (v7M), MPU_RLAR (v8M) */ + case 0xda8: /* MPU_RASR_A1 (v7M), MPU_RLAR_A1 (v8M) */ + case 0xdb0: /* MPU_RASR_A2 (v7M), MPU_RLAR_A2 (v8M) */ + case 0xdb8: /* MPU_RASR_A3 (v7M), MPU_RLAR_A3 (v8M) */ { int region = cpu->env.pmsav7.rnr; + if (arm_feature(&cpu->env, ARM_FEATURE_V8)) { + /* PMSAv8M handling of the aliases is different from v7M: + * aliases A1, A2, A3 override the low two bits of the region + * number in MPU_RNR. + */ + int aliasno = (offset - 0xd9c) / 8; /* 0..3 */ + + region = cpu->env.pmsav7.rnr; + if (aliasno) { + region = deposit32(region, 0, 2, aliasno); + } + if (region >= cpu->pmsav7_dregion) { + return; + } + cpu->env.pmsav8.rlar[region] = value; + tlb_flush(CPU(cpu)); + return; + } + if (region >= cpu->pmsav7_dregion) { return; } @@ -731,6 +812,30 @@ static void nvic_writel(NVICState *s, uint32_t offset, uint32_t value) tlb_flush(CPU(cpu)); break; } + case 0xdc0: /* MPU_MAIR0 */ + if (!arm_feature(&cpu->env, ARM_FEATURE_V8)) { + goto bad_offset; + } + if (cpu->pmsav7_dregion) { + /* Register is RES0 if no MPU regions are implemented */ + cpu->env.pmsav8.mair0 = value; + } + /* We don't need to do anything else because memory attributes + * only affect cacheability, and we don't implement caching. + */ + break; + case 0xdc4: /* MPU_MAIR1 */ + if (!arm_feature(&cpu->env, ARM_FEATURE_V8)) { + goto bad_offset; + } + if (cpu->pmsav7_dregion) { + /* Register is RES0 if no MPU regions are implemented */ + cpu->env.pmsav8.mair1 = value; + } + /* We don't need to do anything else because memory attributes + * only affect cacheability, and we don't implement caching. + */ + break; case 0xf00: /* Software Triggered Interrupt Register */ { int excnum = (value & 0x1ff) + NVIC_FIRST_IRQ; @@ -740,6 +845,7 @@ static void nvic_writel(NVICState *s, uint32_t offset, uint32_t value) break; } default: + bad_offset: qemu_log_mask(LOG_GUEST_ERROR, "NVIC: Bad write offset 0x%x\n", offset); } diff --git a/target/arm/cpu.c b/target/arm/cpu.c index 41ae6ba..8b610de 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -228,17 +228,25 @@ static void arm_cpu_reset(CPUState *s) env->vfp.xregs[ARM_VFP_FPEXC] = 0; #endif - if (arm_feature(env, ARM_FEATURE_PMSA) && - arm_feature(env, ARM_FEATURE_V7)) { + if (arm_feature(env, ARM_FEATURE_PMSA)) { if (cpu->pmsav7_dregion > 0) { - memset(env->pmsav7.drbar, 0, - sizeof(*env->pmsav7.drbar) * cpu->pmsav7_dregion); - memset(env->pmsav7.drsr, 0, - sizeof(*env->pmsav7.drsr) * cpu->pmsav7_dregion); - memset(env->pmsav7.dracr, 0, - sizeof(*env->pmsav7.dracr) * cpu->pmsav7_dregion); + if (arm_feature(env, ARM_FEATURE_V8)) { + memset(env->pmsav8.rbar, 0, + sizeof(*env->pmsav8.rbar) * cpu->pmsav7_dregion); + memset(env->pmsav8.rlar, 0, + sizeof(*env->pmsav8.rlar) * cpu->pmsav7_dregion); + } else if (arm_feature(env, ARM_FEATURE_V7)) { + memset(env->pmsav7.drbar, 0, + sizeof(*env->pmsav7.drbar) * cpu->pmsav7_dregion); + memset(env->pmsav7.drsr, 0, + sizeof(*env->pmsav7.drsr) * cpu->pmsav7_dregion); + memset(env->pmsav7.dracr, 0, + sizeof(*env->pmsav7.dracr) * cpu->pmsav7_dregion); + } } env->pmsav7.rnr = 0; + env->pmsav8.mair0 = 0; + env->pmsav8.mair1 = 0; } set_flush_to_zero(1, &env->vfp.standard_fp_status); @@ -809,9 +817,15 @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp) } if (nr) { - env->pmsav7.drbar = g_new0(uint32_t, nr); - env->pmsav7.drsr = g_new0(uint32_t, nr); - env->pmsav7.dracr = g_new0(uint32_t, nr); + if (arm_feature(env, ARM_FEATURE_V8)) { + /* PMSAv8 */ + env->pmsav8.rbar = g_new0(uint32_t, nr); + env->pmsav8.rlar = g_new0(uint32_t, nr); + } else { + env->pmsav7.drbar = g_new0(uint32_t, nr); + env->pmsav7.drsr = g_new0(uint32_t, nr); + env->pmsav7.dracr = g_new0(uint32_t, nr); + } } } diff --git a/target/arm/machine.c b/target/arm/machine.c index 3193b00..7b6f9de 100644 --- a/target/arm/machine.c +++ b/target/arm/machine.c @@ -159,7 +159,8 @@ static bool pmsav7_needed(void *opaque) CPUARMState *env = &cpu->env; return arm_feature(env, ARM_FEATURE_PMSA) && - arm_feature(env, ARM_FEATURE_V7); + arm_feature(env, ARM_FEATURE_V7) && + !arm_feature(env, ARM_FEATURE_V8); } static bool pmsav7_rgnr_vmstate_validate(void *opaque, int version_id) @@ -209,6 +210,31 @@ static const VMStateDescription vmstate_pmsav7_rnr = { } }; +static bool pmsav8_needed(void *opaque) +{ + ARMCPU *cpu = opaque; + CPUARMState *env = &cpu->env; + + return arm_feature(env, ARM_FEATURE_PMSA) && + arm_feature(env, ARM_FEATURE_V8); +} + +static const VMStateDescription vmstate_pmsav8 = { + .name = "cpu/pmsav8", + .version_id = 1, + .minimum_version_id = 1, + .needed = pmsav8_needed, + .fields = (VMStateField[]) { + VMSTATE_VARRAY_UINT32(env.pmsav8.rbar, ARMCPU, pmsav7_dregion, 0, + vmstate_info_uint32, uint32_t), + VMSTATE_VARRAY_UINT32(env.pmsav8.rlar, ARMCPU, pmsav7_dregion, 0, + vmstate_info_uint32, uint32_t), + VMSTATE_UINT32(env.pmsav8.mair0, ARMCPU), + VMSTATE_UINT32(env.pmsav8.mair1, ARMCPU), + VMSTATE_END_OF_LIST() + } +}; + static int get_cpsr(QEMUFile *f, void *opaque, size_t size, VMStateField *field) { @@ -458,6 +484,7 @@ const VMStateDescription vmstate_arm_cpu = { */ &vmstate_pmsav7_rnr, &vmstate_pmsav7, + &vmstate_pmsav8, NULL } }; From patchwork Thu Sep 7 13:28: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: 111925 Delivered-To: patch@linaro.org Received: by 10.140.94.239 with SMTP id g102csp101117qge; Thu, 7 Sep 2017 06:34:30 -0700 (PDT) X-Google-Smtp-Source: ADKCNb5bwyCIk7bXdAUa9CqewtTX58z23r/83C1lYRoVX9QTdO59+wKgQJ77G17CVnFQVDFXNN2h X-Received: by 10.55.40.196 with SMTP id o65mr3509350qko.325.1504791270368; Thu, 07 Sep 2017 06:34:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1504791270; cv=none; d=google.com; s=arc-20160816; b=hXO6ungxnjKkD0W5XnNUJmeQVug0QhhWL0NbzjkWv6KQWOpH83ucXkyOgmc6YYERar IQXcbtoFEgISa1Mk4yhlrp/97QYqjSID1lERSTZJYGxoy1M26eSqZ5XJpcFHJ5MuI2MF WKw2uxGQHS5XAySVpOxSJ2BIKp3ENWFGyCFcLNUZ9c1udiOGa1AdMniR4VOpsBAh0L0L Z4dhhXeA8wOxxH4xgfdYHNRr4qkNmvbhn1ZYgW7dGQbKFtQ9V94ZIK6uBlTe6aGlmaqO uGNj+7NlPQfU+2aW4X8zsJ60vPP9wjYbFzMeeOftvB3cxLs70lpI474+aHu3dBEwn2oA 5qzg== 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=d+mLENLTGBIiFpt1jXTcglJI7suowzDYE9mlrv/QfOg=; b=AbtI5XMXyycMJ3ujklLyj+wESPYOBKk+B84GizWs3YKVSiYwdY++hhIuiM0GihaUh9 R1DLvZpz/caS92toPwK/2zmhcQYaF1AeH+oJ4gR8NmTvq/NTvJEBN9hBxj8e8Fz72U1+ Wo+5aiSKzUAbFhIWlVtmvZGU3zW25MgXQh9a4VuQ252Sr9VcVHS3pqCbN/tkUOrsiU+e 0OEvJHbT+vEvv+/ahP/Qgd+JOHnHbAxTV23/G4Sia38lWEwiVNh/CCAaV5wpky4g54tT q17wrwiT3PCud1U3unx7HM75rbW8RbAMCR7TxAoIulHXTRtyTUqyKbDgWiWJIiNKNT1r FSQg== 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 w20si2502559qkb.172.2017.09.07.06.34.30 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 07 Sep 2017 06:34: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]:40515 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dpwwu-0005z4-78 for patch@linaro.org; Thu, 07 Sep 2017 09:34:28 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56407) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dpwr2-0000zm-07 for qemu-devel@nongnu.org; Thu, 07 Sep 2017 09:28:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dpwqw-0007cS-5i for qemu-devel@nongnu.org; Thu, 07 Sep 2017 09:28:24 -0400 Received: from orth.archaic.org.uk ([2001:8b0:1d0::2]:37188) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dpwqv-0007a4-UU for qemu-devel@nongnu.org; Thu, 07 Sep 2017 09:28:18 -0400 Received: from pm215 by orth.archaic.org.uk with local (Exim 4.89) (envelope-from ) id 1dpwqn-0001Yr-TT for qemu-devel@nongnu.org; Thu, 07 Sep 2017 14:28:09 +0100 From: Peter Maydell To: qemu-devel@nongnu.org Date: Thu, 7 Sep 2017 14:28:02 +0100 Message-Id: <1504790904-17018-10-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1504790904-17018-1-git-send-email-peter.maydell@linaro.org> References: <1504790904-17018-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/31] target/arm: Implement new PMSAv8 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" Implement the behavioural side of the new PMSAv8 specification. Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson Message-id: 1503414539-28762-3-git-send-email-peter.maydell@linaro.org --- target/arm/helper.c | 111 +++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 110 insertions(+), 1 deletion(-) -- 2.7.4 diff --git a/target/arm/helper.c b/target/arm/helper.c index 37e7fd9..bab3848 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -8411,6 +8411,111 @@ static bool get_phys_addr_pmsav7(CPUARMState *env, uint32_t address, return !(*prot & (1 << access_type)); } +static bool get_phys_addr_pmsav8(CPUARMState *env, uint32_t address, + MMUAccessType access_type, ARMMMUIdx mmu_idx, + hwaddr *phys_ptr, int *prot, uint32_t *fsr) +{ + ARMCPU *cpu = arm_env_get_cpu(env); + bool is_user = regime_is_user(env, mmu_idx); + int n; + int matchregion = -1; + bool hit = false; + + *phys_ptr = address; + *prot = 0; + + /* Unlike the ARM ARM pseudocode, we don't need to check whether this + * was an exception vector read from the vector table (which is always + * done using the default system address map), because those accesses + * are done in arm_v7m_load_vector(), which always does a direct + * read using address_space_ldl(), rather than going via this function. + */ + if (regime_translation_disabled(env, mmu_idx)) { /* MPU disabled */ + hit = true; + } else if (m_is_ppb_region(env, address)) { + hit = true; + } else if (pmsav7_use_background_region(cpu, mmu_idx, is_user)) { + hit = true; + } else { + for (n = (int)cpu->pmsav7_dregion - 1; n >= 0; n--) { + /* region search */ + /* Note that the base address is bits [31:5] from the register + * with bits [4:0] all zeroes, but the limit address is bits + * [31:5] from the register with bits [4:0] all ones. + */ + uint32_t base = env->pmsav8.rbar[n] & ~0x1f; + uint32_t limit = env->pmsav8.rlar[n] | 0x1f; + + if (!(env->pmsav8.rlar[n] & 0x1)) { + /* Region disabled */ + continue; + } + + if (address < base || address > limit) { + continue; + } + + if (hit) { + /* Multiple regions match -- always a failure (unlike + * PMSAv7 where highest-numbered-region wins) + */ + *fsr = 0x00d; /* permission fault */ + return true; + } + + matchregion = n; + hit = true; + + if (base & ~TARGET_PAGE_MASK) { + qemu_log_mask(LOG_UNIMP, + "MPU_RBAR[%d]: No support for MPU region base" + "address of 0x%" PRIx32 ". Minimum alignment is " + "%d\n", + n, base, TARGET_PAGE_BITS); + continue; + } + if ((limit + 1) & ~TARGET_PAGE_MASK) { + qemu_log_mask(LOG_UNIMP, + "MPU_RBAR[%d]: No support for MPU region limit" + "address of 0x%" PRIx32 ". Minimum alignment is " + "%d\n", + n, limit, TARGET_PAGE_BITS); + continue; + } + } + } + + if (!hit) { + /* background fault */ + *fsr = 0; + return true; + } + + if (matchregion == -1) { + /* hit using the background region */ + get_phys_addr_pmsav7_default(env, mmu_idx, address, prot); + } else { + uint32_t ap = extract32(env->pmsav8.rbar[matchregion], 1, 2); + uint32_t xn = extract32(env->pmsav8.rbar[matchregion], 0, 1); + + if (m_is_system_region(env, address)) { + /* System space is always execute never */ + xn = 1; + } + + *prot = simple_ap_to_rw_prot(env, mmu_idx, ap); + if (*prot && !xn) { + *prot |= PAGE_EXEC; + } + /* We don't need to look the attribute up in the MAIR0/MAIR1 + * registers because that only tells us about cacheability. + */ + } + + *fsr = 0x00d; /* Permission fault */ + return !(*prot & (1 << access_type)); +} + static bool get_phys_addr_pmsav5(CPUARMState *env, uint32_t address, MMUAccessType access_type, ARMMMUIdx mmu_idx, hwaddr *phys_ptr, int *prot, uint32_t *fsr) @@ -8580,7 +8685,11 @@ static bool get_phys_addr(CPUARMState *env, target_ulong address, bool ret; *page_size = TARGET_PAGE_SIZE; - if (arm_feature(env, ARM_FEATURE_V7)) { + if (arm_feature(env, ARM_FEATURE_V8)) { + /* PMSAv8 */ + ret = get_phys_addr_pmsav8(env, address, access_type, mmu_idx, + phys_ptr, prot, fsr); + } else if (arm_feature(env, ARM_FEATURE_V7)) { /* PMSAv7 */ ret = get_phys_addr_pmsav7(env, address, access_type, mmu_idx, phys_ptr, prot, fsr); From patchwork Thu Sep 7 13:28: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: 111924 Delivered-To: patch@linaro.org Received: by 10.140.94.239 with SMTP id g102csp100900qge; Thu, 7 Sep 2017 06:34:20 -0700 (PDT) X-Google-Smtp-Source: AOwi7QBJCJJT4VEmEJDRMC9eV06iz3YJbDegte3k0b6069iEk6J5xSYQ2aWZbPURewTN55w5GAAW X-Received: by 10.233.244.72 with SMTP id z8mr3736689qkl.186.1504791260096; Thu, 07 Sep 2017 06:34:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1504791260; cv=none; d=google.com; s=arc-20160816; b=IZLUWJAzZPo3hvpAimcE+YZujFIMPm0l08nPXt3o0DI/qT4JIdO6mk/mFBLs8jAYXA zls1JYe2tVZFhgY+ciQZxUBtl5xekBa6GPFvPMIO+jqFnWkn5D6qgIzlo418tuP+mTAF 7iCWXL2f+6sY24vjAjoXU8i0DLgrweB1WBCzP467Gq12hBTQ2fIjCXIlRa94qP4N4NXh FJ4w5rydJBDgDMmEK8A1fIptCw5ZgAxBy6Et3xM5LRQcKSOvGuQQ6N+eqbzNTJFV5GpE FMOvrzgXsYstyq9QaTrlPByo7VcjfDS5PHgRF/iErSu7WrDxevarC0oKExGtZh8nBdHi faCg== 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=OtFNbXChUQo10Gt+A7vqlwuZhbqH+hacYYQmRyxDgDM=; b=ZvTHafAfq4JT1Ihl93mIb5n/h63qUk8fXT24yV1rZvNHc7TcnUoh542E+Y47W3byLG Jik/LCFjFf99mvq0H5+1kd81qe6JSrF5AnngvfEHGpIK+bghOTeraSQG98q84XL0J+mf B6ZZvE2/nIOsKkVrAx9DOCEmws6lBAYBIPBI90DdAGayb3ycFG4S3mPD0+j0+HQ8JXwp pgAY0p3BrqtbMIwLt8pCo3YTbX4qLpxjQHIr7KP5t2J4Vs3tOpeCFt9nQqtK+sE9aGEu csP83J0VW+yjGRYNIsybesCMjTJvpaqXN+NSNwS3h+y1DjzfNRSqC+8zE984XvQJpzNf YLLg== 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 c20si2969422qta.516.2017.09.07.06.34.19 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 07 Sep 2017 06:34:20 -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]:40513 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dpwwj-0005qF-WF for patch@linaro.org; Thu, 07 Sep 2017 09:34:18 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56414) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dpwr2-0000zp-6N for qemu-devel@nongnu.org; Thu, 07 Sep 2017 09:28:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dpwqv-0007cJ-QF for qemu-devel@nongnu.org; Thu, 07 Sep 2017 09:28:24 -0400 Received: from orth.archaic.org.uk ([2001:8b0:1d0::2]:37186) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dpwqv-0007Xf-H6 for qemu-devel@nongnu.org; Thu, 07 Sep 2017 09:28:17 -0400 Received: from pm215 by orth.archaic.org.uk with local (Exim 4.89) (envelope-from ) id 1dpwqo-0001ZH-Hv for qemu-devel@nongnu.org; Thu, 07 Sep 2017 14:28:10 +0100 From: Peter Maydell To: qemu-devel@nongnu.org Date: Thu, 7 Sep 2017 14:28:03 +0100 Message-Id: <1504790904-17018-11-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1504790904-17018-1-git-send-email-peter.maydell@linaro.org> References: <1504790904-17018-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/31] target/arm: Add state field, feature bit and migration for v8M secure 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" As the first step in implementing ARM v8M's security extension: * add a new feature bit ARM_FEATURE_M_SECURITY * add the CPU state field that indicates whether the CPU is currently in the secure state * add a migration subsection for this new state (we will add the Secure copies of banked register state to this subsection in later patches) * add a #define for the one new-in-v8M exception type * make the CPU debug log print S/NS status Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson Message-id: 1503414539-28762-4-git-send-email-peter.maydell@linaro.org --- target/arm/cpu.h | 3 +++ target/arm/cpu.c | 4 ++++ target/arm/machine.c | 20 ++++++++++++++++++++ target/arm/translate.c | 8 +++++++- 4 files changed, 34 insertions(+), 1 deletion(-) -- 2.7.4 diff --git a/target/arm/cpu.h b/target/arm/cpu.h index 9fd5de7..02919a3 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -66,6 +66,7 @@ #define ARMV7M_EXCP_MEM 4 #define ARMV7M_EXCP_BUS 5 #define ARMV7M_EXCP_USAGE 6 +#define ARMV7M_EXCP_SECURE 7 #define ARMV7M_EXCP_SVC 11 #define ARMV7M_EXCP_DEBUG 12 #define ARMV7M_EXCP_PENDSV 14 @@ -420,6 +421,7 @@ typedef struct CPUARMState { int exception; uint32_t primask; uint32_t faultmask; + uint32_t secure; /* Is CPU in Secure state? (not guest visible) */ } v7m; /* Information associated with an exception about to be taken: @@ -1263,6 +1265,7 @@ enum arm_features { ARM_FEATURE_THUMB_DSP, /* DSP insns supported in the Thumb encodings */ ARM_FEATURE_PMU, /* has PMU support */ ARM_FEATURE_VBAR, /* has cp15 VBAR */ + ARM_FEATURE_M_SECURITY, /* M profile Security Extension */ }; static inline int arm_feature(CPUARMState *env, int feature) diff --git a/target/arm/cpu.c b/target/arm/cpu.c index 8b610de..f32317e 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -185,6 +185,10 @@ static void arm_cpu_reset(CPUState *s) uint32_t initial_pc; /* Loaded from 0x4 */ uint8_t *rom; + if (arm_feature(env, ARM_FEATURE_M_SECURITY)) { + env->v7m.secure = true; + } + /* 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/machine.c b/target/arm/machine.c index 7b6f9de..f70fcf3 100644 --- a/target/arm/machine.c +++ b/target/arm/machine.c @@ -235,6 +235,25 @@ static const VMStateDescription vmstate_pmsav8 = { } }; +static bool m_security_needed(void *opaque) +{ + ARMCPU *cpu = opaque; + CPUARMState *env = &cpu->env; + + return arm_feature(env, ARM_FEATURE_M_SECURITY); +} + +static const VMStateDescription vmstate_m_security = { + .name = "cpu/m-security", + .version_id = 1, + .minimum_version_id = 1, + .needed = m_security_needed, + .fields = (VMStateField[]) { + VMSTATE_UINT32(env.v7m.secure, ARMCPU), + VMSTATE_END_OF_LIST() + } +}; + static int get_cpsr(QEMUFile *f, void *opaque, size_t size, VMStateField *field) { @@ -485,6 +504,7 @@ const VMStateDescription vmstate_arm_cpu = { &vmstate_pmsav7_rnr, &vmstate_pmsav7, &vmstate_pmsav8, + &vmstate_m_security, NULL } }; diff --git a/target/arm/translate.c b/target/arm/translate.c index e52a6d7..dea0a6f 100644 --- a/target/arm/translate.c +++ b/target/arm/translate.c @@ -12232,6 +12232,11 @@ void arm_cpu_dump_state(CPUState *cs, FILE *f, fprintf_function cpu_fprintf, if (arm_feature(env, ARM_FEATURE_M)) { uint32_t xpsr = xpsr_read(env); const char *mode; + const char *ns_status = ""; + + if (arm_feature(env, ARM_FEATURE_M_SECURITY)) { + ns_status = env->v7m.secure ? "S " : "NS "; + } if (xpsr & XPSR_EXCP) { mode = "handler"; @@ -12243,13 +12248,14 @@ void arm_cpu_dump_state(CPUState *cs, FILE *f, fprintf_function cpu_fprintf, } } - cpu_fprintf(f, "XPSR=%08x %c%c%c%c %c %s\n", + cpu_fprintf(f, "XPSR=%08x %c%c%c%c %c %s%s\n", xpsr, xpsr & XPSR_N ? 'N' : '-', xpsr & XPSR_Z ? 'Z' : '-', xpsr & XPSR_C ? 'C' : '-', xpsr & XPSR_V ? 'V' : '-', xpsr & XPSR_T ? 'T' : 'A', + ns_status, mode); } else { uint32_t psr = cpsr_read(env); From patchwork Thu Sep 7 13:28:04 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 111919 Delivered-To: patch@linaro.org Received: by 10.140.94.239 with SMTP id g102csp97330qge; Thu, 7 Sep 2017 06:31:36 -0700 (PDT) X-Google-Smtp-Source: ADKCNb5QzTvEbFYEAcjG+BV8OufyrQSjg+i+62NNjtasz0X0ANzsbtMEL1s4ZHIdGRA0AvOsiGBd X-Received: by 10.237.45.7 with SMTP id h7mr3780370qtd.158.1504791096408; Thu, 07 Sep 2017 06:31:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1504791096; cv=none; d=google.com; s=arc-20160816; b=07cXLK8z4h2X/bFtQVwizk5GYSNGGA6sz+LDQN7m2H9pSq2wADPVicDWiyvdqAr9bV PCwh7Ox1gy/zmG85iF+smKJCeLh+TITqyVGuUVlgOZUxkqucZjNi0go+o1S8wCDVgKUj PJydhCDGyouvanaiaAjZfvCCjADLsdXVUDW9FfExue8bLMbmHt3zIFmDKdu06R/FqY9Z mPR3lEVlC6bKoszsxI9memSlvXIXmVLoXJLy23vVaZzGMS32GGJPlW6lm30cvBTF5Rcc g2Nggzs0/Tx5B9zEy3EbsXNtrAE7FWydnoei445/b4EF2kPA7HCdqls1W8S7Dp5iYGK0 EDyw== 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=JXM2uwF1R9sokynIaqbt4jo4+9oTOWX/mDJCIKT0soM=; b=zBldN7kEXZWk3fmvaLYjC+kQQx/i6EleVlOKAA6m/ZvZx0durRwZY5MvAj392HOtlO nA9z6TVgMXht/YaC4ZyB8abc4qyltBtIyZR3feMh/DlM/S5bF2SQ9maiFUP7ix1NxLia 1NYHa0iS9kq7StGIO5FL6ROK2JvuTY/EGdMHUJlmhdw6qCG2USEOx3FO0WlC2XCy3g7P +F/81tYehuvQAkf24geYOy/a3Xxgp98koYW9pViuu6I3I9H1/jp9lqb8lt9AIT/VaxmV Uh0ncqlh9P3NHe+9jz0XvJzX3b3Lo4Y4tpbgBbPzMX2ZRX7QDdMWkdB0DEo7nGl7QjTF rJcw== 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 s199si2841712qke.10.2017.09.07.06.31.36 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 07 Sep 2017 06:31:36 -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]:40507 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dpwu6-0003NC-7s for patch@linaro.org; Thu, 07 Sep 2017 09:31:34 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56402) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dpwr1-0000zl-In for qemu-devel@nongnu.org; Thu, 07 Sep 2017 09:28:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dpwqv-0007bx-Ar for qemu-devel@nongnu.org; Thu, 07 Sep 2017 09:28:23 -0400 Received: from orth.archaic.org.uk ([2001:8b0:1d0::2]:37190) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dpwqv-0007ak-3z for qemu-devel@nongnu.org; Thu, 07 Sep 2017 09:28:17 -0400 Received: from pm215 by orth.archaic.org.uk with local (Exim 4.89) (envelope-from ) id 1dpwqp-0001Zi-6U for qemu-devel@nongnu.org; Thu, 07 Sep 2017 14:28:11 +0100 From: Peter Maydell To: qemu-devel@nongnu.org Date: Thu, 7 Sep 2017 14:28:04 +0100 Message-Id: <1504790904-17018-12-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1504790904-17018-1-git-send-email-peter.maydell@linaro.org> References: <1504790904-17018-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/31] target/arm: Register second AddressSpace for secure v8M CPUs 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" If a v8M CPU supports the security extension then we need to give it two AddressSpaces, the same way we do already for an A profile core with EL3. Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson Message-id: 1503414539-28762-5-git-send-email-peter.maydell@linaro.org --- target/arm/cpu.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) -- 2.7.4 diff --git a/target/arm/cpu.c b/target/arm/cpu.c index f32317e..ae866be 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -843,22 +843,21 @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp) init_cpreg_list(cpu); #ifndef CONFIG_USER_ONLY - if (cpu->has_el3) { - cs->num_ases = 2; - } else { - cs->num_ases = 1; - } - - if (cpu->has_el3) { + if (cpu->has_el3 || arm_feature(env, ARM_FEATURE_M_SECURITY)) { AddressSpace *as; + cs->num_ases = 2; + if (!cpu->secure_memory) { cpu->secure_memory = cs->memory; } as = address_space_init_shareable(cpu->secure_memory, "cpu-secure-memory"); cpu_address_space_init(cs, as, ARMASIdx_S); + } else { + cs->num_ases = 1; } + cpu_address_space_init(cs, address_space_init_shareable(cs->memory, "cpu-memory"), From patchwork Thu Sep 7 13:28: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: 111917 Delivered-To: patch@linaro.org Received: by 10.140.94.239 with SMTP id g102csp93700qge; Thu, 7 Sep 2017 06:28:56 -0700 (PDT) X-Google-Smtp-Source: AOwi7QDW9VLYX1UEdeySihpSSAHdv8h8ocaAdKlfuvfdKlkGQSAz9uwedVXSLl8EGDb4q5SqCeS8 X-Received: by 10.200.3.14 with SMTP id q14mr3621028qtg.336.1504790936487; Thu, 07 Sep 2017 06:28:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1504790936; cv=none; d=google.com; s=arc-20160816; b=ZDPgZNlK2L25c/fjEMZiNERzgUrde3tc/6t5dfBJebjvgBA7AjAp89KsSSJWEedPjB TBwSxNCdufn35E9LWaN29EKeeL54cwAQTMlsbbUKkNEEfUnWbRBdmGEkHh1j5WbXShRK 6CjbwVWn0lG6+RD5ttgGd21QXFapwwvZg276VfOETj02Bmr7fJ0o+8vfFiRlOSpx5ZSV Xq9ttKjE348ZfHOdlz8TI6FZ+mOLMaqqf261eRaZwnjRVXPYAzgULUipYB+PF1B6p0V7 x4SJifsPrN4/gHsbPTeSjqAhWvmJW6fecMmO8+BH4fkKoj/6usA/VOy3YmJwVZDiKiBO zABQ== 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=ZW5/xjqWY7tuGnzN10j684bEhgBSZG0akscXmDE61Ak=; b=DFFaeKcT9aZQDRH8UdXSlnr2adxBHHyLZhxU/WQY5XFuJWfKdslaWbil2eZJSBeAsG y0Gl8HnVIaUAgCbGrY0BSqBuW1ZX3Tnogh8Mswf7d39SXefZ73LWMzbCyWqqDcUU1Ooe +1fDe8OXr8cS9hIAR33m86V0svq+BuedPkXkTVcBGhr+jSafrDg63gpVebWu0H+QETDm njlp94lsFcZmWTt+a2qoBsN5KD7sO1EBesgmpDn9xYfYZ8HcIRYBfyfG/mPvN2AlEtAs UWbNhNryL0uaYft5g6TltpUVYiHJiNoy0pcko1HqLO+AERKxB9r6vL8CL0aoxSe/7FAI fzhQ== 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 v15si2866155qkl.378.2017.09.07.06.28.55 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 07 Sep 2017 06:28: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]:40496 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dpwrW-00013p-46 for patch@linaro.org; Thu, 07 Sep 2017 09:28:54 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56385) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dpwqz-0000zi-Vf for qemu-devel@nongnu.org; Thu, 07 Sep 2017 09:28:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dpwqu-0007bb-QF for qemu-devel@nongnu.org; Thu, 07 Sep 2017 09:28:22 -0400 Received: from orth.archaic.org.uk ([2001:8b0:1d0::2]:37186) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dpwqu-0007Xf-Hf for qemu-devel@nongnu.org; Thu, 07 Sep 2017 09:28:16 -0400 Received: from pm215 by orth.archaic.org.uk with local (Exim 4.89) (envelope-from ) id 1dpwqp-0001a8-Rr for qemu-devel@nongnu.org; Thu, 07 Sep 2017 14:28:11 +0100 From: Peter Maydell To: qemu-devel@nongnu.org Date: Thu, 7 Sep 2017 14:28:05 +0100 Message-Id: <1504790904-17018-13-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1504790904-17018-1-git-send-email-peter.maydell@linaro.org> References: <1504790904-17018-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 12/31] target/arm: Add MMU indexes for secure v8M 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" Now that MPU lookups can return different results for v8M when the CPU is in secure vs non-secure state, we need to have separate MMU indexes; add the secure counterparts to the existing three M profile MMU indexes. Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson Message-id: 1503414539-28762-6-git-send-email-peter.maydell@linaro.org --- target/arm/cpu.h | 19 +++++++++++++++++-- target/arm/helper.c | 9 ++++++++- 2 files changed, 25 insertions(+), 3 deletions(-) -- 2.7.4 diff --git a/target/arm/cpu.h b/target/arm/cpu.h index 02919a3..d93fe96 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -2103,6 +2103,10 @@ static inline bool arm_excp_unmasked(CPUState *cs, unsigned int excp_idx, * Execution priority negative (this is like privileged, but the * MPU HFNMIENA bit means that it may have different access permission * check results to normal privileged code, so can't share a TLB). + * If the CPU supports the v8M Security Extension then there are also: + * Secure User + * Secure Privileged + * Secure, execution priority negative * * The ARMMMUIdx and the mmu index value used by the core QEMU TLB code * are not quite the same -- different CPU types (most notably M profile @@ -2140,6 +2144,9 @@ typedef enum ARMMMUIdx { ARMMMUIdx_MUser = 0 | ARM_MMU_IDX_M, ARMMMUIdx_MPriv = 1 | ARM_MMU_IDX_M, ARMMMUIdx_MNegPri = 2 | ARM_MMU_IDX_M, + ARMMMUIdx_MSUser = 3 | ARM_MMU_IDX_M, + ARMMMUIdx_MSPriv = 4 | ARM_MMU_IDX_M, + ARMMMUIdx_MSNegPri = 5 | ARM_MMU_IDX_M, /* Indexes below here don't have TLBs and are used only for AT system * instructions or for the first stage of an S12 page table walk. */ @@ -2161,6 +2168,9 @@ typedef enum ARMMMUIdxBit { ARMMMUIdxBit_MUser = 1 << 0, ARMMMUIdxBit_MPriv = 1 << 1, ARMMMUIdxBit_MNegPri = 1 << 2, + ARMMMUIdxBit_MSUser = 1 << 3, + ARMMMUIdxBit_MSPriv = 1 << 4, + ARMMMUIdxBit_MSNegPri = 1 << 5, } ARMMMUIdxBit; #define MMU_USER_IDX 0 @@ -2186,7 +2196,8 @@ static inline int arm_mmu_idx_to_el(ARMMMUIdx mmu_idx) case ARM_MMU_IDX_A: return mmu_idx & 3; case ARM_MMU_IDX_M: - return mmu_idx == ARMMMUIdx_MUser ? 0 : 1; + return (mmu_idx == ARMMMUIdx_MUser || mmu_idx == ARMMMUIdx_MSUser) + ? 0 : 1; default: g_assert_not_reached(); } @@ -2205,7 +2216,11 @@ static inline int cpu_mmu_index(CPUARMState *env, bool ifetch) */ if ((env->v7m.exception > 0 && env->v7m.exception <= 3) || env->v7m.faultmask) { - return arm_to_core_mmu_idx(ARMMMUIdx_MNegPri); + mmu_idx = ARMMMUIdx_MNegPri; + } + + if (env->v7m.secure) { + mmu_idx += ARMMMUIdx_MSUser; } return arm_to_core_mmu_idx(mmu_idx); diff --git a/target/arm/helper.c b/target/arm/helper.c index bab3848..3062c47 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -7032,6 +7032,9 @@ static inline uint32_t regime_el(CPUARMState *env, ARMMMUIdx mmu_idx) case ARMMMUIdx_MPriv: case ARMMMUIdx_MNegPri: case ARMMMUIdx_MUser: + case ARMMMUIdx_MSPriv: + case ARMMMUIdx_MSNegPri: + case ARMMMUIdx_MSUser: return 1; default: g_assert_not_reached(); @@ -7055,6 +7058,9 @@ static inline bool regime_is_secure(CPUARMState *env, ARMMMUIdx mmu_idx) case ARMMMUIdx_S1E3: case ARMMMUIdx_S1SE0: case ARMMMUIdx_S1SE1: + case ARMMMUIdx_MSPriv: + case ARMMMUIdx_MSNegPri: + case ARMMMUIdx_MSUser: return true; default: g_assert_not_reached(); @@ -7076,7 +7082,8 @@ static inline bool regime_translation_disabled(CPUARMState *env, (R_V7M_MPU_CTRL_ENABLE_MASK | R_V7M_MPU_CTRL_HFNMIENA_MASK)) { case R_V7M_MPU_CTRL_ENABLE_MASK: /* Enabled, but not for HardFault and NMI */ - return mmu_idx == ARMMMUIdx_MNegPri; + return mmu_idx == ARMMMUIdx_MNegPri || + mmu_idx == ARMMMUIdx_MSNegPri; case R_V7M_MPU_CTRL_ENABLE_MASK | R_V7M_MPU_CTRL_HFNMIENA_MASK: /* Enabled for all cases */ return false; From patchwork Thu Sep 7 13:28: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: 111923 Delivered-To: patch@linaro.org Received: by 10.140.94.239 with SMTP id g102csp99593qge; Thu, 7 Sep 2017 06:33:24 -0700 (PDT) X-Google-Smtp-Source: AOwi7QAEJVqirRYnh4yWVe8NQ3qYCDj2C9a3tA2q5fYZpxuWpZCPAlIWVa+5s95kQyUZvhn0TTtM X-Received: by 10.55.3.133 with SMTP id 127mr3980785qkd.42.1504791201844; Thu, 07 Sep 2017 06:33:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1504791201; cv=none; d=google.com; s=arc-20160816; b=dW/K7jn8MqxCe3Hnqf0yXU1AO7nscUsPsJyOttRI8aHc58QbqPYhvj31OQ1AeBhUGe 5n8l+eLWOc4WBuLI9gCiCyII/bP0Ix2jEKHrDEsD2gPoEOam4PGlxuDxGHYmvTSHMPoj Wlqt3V606+sHL1gXJ5ac9oB2FBOMzopJkVaFMq+gkFq3IvvVeq5wNhVloMP15XgL4EfU MsfVegqQi3NGBk943ZdALxhm1vJHwfBp9ufzwPIiPQ6wilhDXzfXXkH3qNIFNV6i693B rBTYDaFme/t/EINrjm+DpvnO1c1XxPNnxwlA6SaVHDX0PqQw6GnbQ67cUTblrPZY/xpU l51Q== 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=sd+JCEOlCGw9YmyPyLykIO59Y19BpMDqyRfRbYTHG1Q=; b=U5g750QRiBliAE1EoJIjQFWJC/6tu4JymDl/N3o+CDG18fKPtx7PwZT2bvRc+c750n rTJeKjJaFc4kIAvvDYx824LS12NmTPT3roZl3LWxboA04n4XYkJzt2uleeRamnyJVKW4 F1lzeuFTHsKHYIpD31DBWKQJQrDtziBq4Qu8A+1bJuXZrTDELQOHwVRx2UV6fvQPbfWz rk1+mZbM8v4ssoJWYk4kIUqDWAjKAsOhC6aCBBkhCCnaHlkjGolcnUZ/fTv+S5nrlT5Z 7vORvfjXM9TY5nS2MeCsV7G+o/hEYqyvkX7YUlQE4zEpP/rWrU/Q1smPEpHURi8WXRTJ L8Gg== 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 x5si2877626qte.183.2017.09.07.06.33.21 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 07 Sep 2017 06:33: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]:40510 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dpwvn-0004aL-DM for patch@linaro.org; Thu, 07 Sep 2017 09:33:19 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56370) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dpwqz-0000zZ-6Y for qemu-devel@nongnu.org; Thu, 07 Sep 2017 09:28:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dpwqu-0007b8-4M for qemu-devel@nongnu.org; Thu, 07 Sep 2017 09:28:21 -0400 Received: from orth.archaic.org.uk ([2001:8b0:1d0::2]:37188) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dpwqt-0007a4-Sv for qemu-devel@nongnu.org; Thu, 07 Sep 2017 09:28:16 -0400 Received: from pm215 by orth.archaic.org.uk with local (Exim 4.89) (envelope-from ) id 1dpwqq-0001aZ-Ge for qemu-devel@nongnu.org; Thu, 07 Sep 2017 14:28:12 +0100 From: Peter Maydell To: qemu-devel@nongnu.org Date: Thu, 7 Sep 2017 14:28:06 +0100 Message-Id: <1504790904-17018-14-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1504790904-17018-1-git-send-email-peter.maydell@linaro.org> References: <1504790904-17018-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 13/31] target/arm: Make BASEPRI register banked for v8M 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 BASEPRI register banked if v8M security extensions are enabled. Note that we do not yet implement the functionality of the new AIRCR.PRIS bit (which allows the effect of the NS copy of BASEPRI to be restricted). Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson Message-id: 1503414539-28762-7-git-send-email-peter.maydell@linaro.org --- target/arm/cpu.h | 14 +++++++++++++- hw/intc/armv7m_nvic.c | 4 ++-- target/arm/helper.c | 10 ++++++---- target/arm/machine.c | 3 ++- 4 files changed, 23 insertions(+), 8 deletions(-) -- 2.7.4 diff --git a/target/arm/cpu.h b/target/arm/cpu.h index d93fe96..273abc3 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -72,6 +72,18 @@ #define ARMV7M_EXCP_PENDSV 14 #define ARMV7M_EXCP_SYSTICK 15 +/* For M profile, some registers are banked secure vs non-secure; + * these are represented as a 2-element array where the first element + * is the non-secure copy and the second is the secure copy. + * When the CPU does not have implement the security extension then + * only the first element is used. + * This means that the copy for the current security state can be + * accessed via env->registerfield[env->v7m.secure] (whether the security + * extension is implemented or not). + */ +#define M_REG_NS 0 +#define M_REG_S 1 + /* ARM-specific interrupt pending bits. */ #define CPU_INTERRUPT_FIQ CPU_INTERRUPT_TGT_EXT_1 #define CPU_INTERRUPT_VIRQ CPU_INTERRUPT_TGT_EXT_2 @@ -409,7 +421,7 @@ typedef struct CPUARMState { struct { uint32_t other_sp; uint32_t vecbase; - uint32_t basepri; + uint32_t basepri[2]; uint32_t control; uint32_t ccr; /* Configuration and Control */ uint32_t cfsr; /* Configurable Fault Status */ diff --git a/hw/intc/armv7m_nvic.c b/hw/intc/armv7m_nvic.c index c0dbbad..2a41e5d 100644 --- a/hw/intc/armv7m_nvic.c +++ b/hw/intc/armv7m_nvic.c @@ -171,8 +171,8 @@ static inline int nvic_exec_prio(NVICState *s) running = -1; } else if (env->v7m.primask) { running = 0; - } else if (env->v7m.basepri > 0) { - running = env->v7m.basepri & nvic_gprio_mask(s); + } else if (env->v7m.basepri[env->v7m.secure] > 0) { + running = env->v7m.basepri[env->v7m.secure] & nvic_gprio_mask(s); } else { running = NVIC_NOEXC_PRIO; /* lower than any possible priority */ } diff --git a/target/arm/helper.c b/target/arm/helper.c index 3062c47..7007266 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -8833,7 +8833,7 @@ uint32_t HELPER(v7m_mrs)(CPUARMState *env, uint32_t reg) return env->v7m.primask; case 17: /* BASEPRI */ case 18: /* BASEPRI_MAX */ - return env->v7m.basepri; + return env->v7m.basepri[env->v7m.secure]; case 19: /* FAULTMASK */ return env->v7m.faultmask; default: @@ -8893,12 +8893,14 @@ void HELPER(v7m_msr)(CPUARMState *env, uint32_t maskreg, uint32_t val) env->v7m.primask = val & 1; break; case 17: /* BASEPRI */ - env->v7m.basepri = val & 0xff; + env->v7m.basepri[env->v7m.secure] = val & 0xff; break; case 18: /* BASEPRI_MAX */ val &= 0xff; - if (val != 0 && (val < env->v7m.basepri || env->v7m.basepri == 0)) - env->v7m.basepri = val; + if (val != 0 && (val < env->v7m.basepri[env->v7m.secure] + || env->v7m.basepri[env->v7m.secure] == 0)) { + env->v7m.basepri[env->v7m.secure] = val; + } break; case 19: /* FAULTMASK */ env->v7m.faultmask = val & 1; diff --git a/target/arm/machine.c b/target/arm/machine.c index f70fcf3..dbb432d 100644 --- a/target/arm/machine.c +++ b/target/arm/machine.c @@ -115,7 +115,7 @@ static const VMStateDescription vmstate_m = { .needed = m_needed, .fields = (VMStateField[]) { VMSTATE_UINT32(env.v7m.vecbase, ARMCPU), - VMSTATE_UINT32(env.v7m.basepri, ARMCPU), + VMSTATE_UINT32(env.v7m.basepri[M_REG_NS], ARMCPU), VMSTATE_UINT32(env.v7m.control, ARMCPU), VMSTATE_UINT32(env.v7m.ccr, ARMCPU), VMSTATE_UINT32(env.v7m.cfsr, ARMCPU), @@ -250,6 +250,7 @@ static const VMStateDescription vmstate_m_security = { .needed = m_security_needed, .fields = (VMStateField[]) { VMSTATE_UINT32(env.v7m.secure, ARMCPU), + VMSTATE_UINT32(env.v7m.basepri[M_REG_S], ARMCPU), VMSTATE_END_OF_LIST() } }; From patchwork Thu Sep 7 13:28: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: 111915 Delivered-To: patch@linaro.org Received: by 10.140.94.239 with SMTP id g102csp93457qge; Thu, 7 Sep 2017 06:28:45 -0700 (PDT) X-Google-Smtp-Source: ADKCNb63YlM6nwt0lk7vvubB9LqU8bqbLWVrrVsWPvCQrJINMbmJBoXSi7nDtiYDooG386fp8+bn X-Received: by 10.55.97.208 with SMTP id v199mr3466576qkb.165.1504790925407; Thu, 07 Sep 2017 06:28:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1504790925; cv=none; d=google.com; s=arc-20160816; b=v2TaBYS4f7FZciiQ13qDQK2LvFBdVtia8lUxjzc1x90B8Q0egxkTAk+5JPFEqdzYmb NNCtnRitHNmOluwvZxbjOjK233Kdtf/+GJ+oe3bjPNsKGEKtb0fnhltA47AG3ek2u5bf dF852W/SU5gGZDxVaRUsamcOBok1dvr07U6jZ8vHX0AbhADtBGzV4Sehkir1r2WLU4Cb eSQ1IBRdAIvGVLUBdmbyRFS0EyoTLxqQt40tQJJPKdgM8OcumxITiOvR/d6LYHrE+PyX hv0EnYr3ctmiv3wzJLNYs+dQhJsLJbTWD7aKD1ElgIbLmG8imGTonWGrEsEObfZg3txs 80Zg== 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=fU790eCLUu+TPkShPCeSi9PARCbOfoDz6l7SRNPdoBM=; b=r4xbrx5Fpmo61o5qETZyS8//gOrLsCEt8KT1BllAUnQOeQ1KdodfrDZ3xuIq+VV0dz vibbtIvwraNEbKlWtJrFaXPgnmE7H74TX8oQEPN27l12z/1mBLA8Bmr/pmvY0DLx+j8U GyGkdaGh5XAHkn+MntNUxrvMqbIdjxeE2Pd4+J4T0B0/EPu+nICO4ZrIrIKNJzmSvCwi 9oNXuVd6ELF0Csdik3+etdcfQxZlE9CFsKAOO5pwMr/aivyH754f+spHt9WeLr71LYn5 WPBoceJEnOA/ycPv0/Vs4l7Tr0Ydfp2otlrb/V6vA1jOhycT4X5VsvC8AC2a+S0J6eiu 0Hew== 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 s199si2836211qke.10.2017.09.07.06.28.45 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 07 Sep 2017 06:28: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]:40494 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dpwrL-00010W-8M for patch@linaro.org; Thu, 07 Sep 2017 09:28:43 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56327) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dpwqx-0000zP-Tr for qemu-devel@nongnu.org; Thu, 07 Sep 2017 09:28:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dpwqs-0007aK-Rx for qemu-devel@nongnu.org; Thu, 07 Sep 2017 09:28:19 -0400 Received: from orth.archaic.org.uk ([2001:8b0:1d0::2]:37186) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dpwqs-0007Xf-JK for qemu-devel@nongnu.org; Thu, 07 Sep 2017 09:28:14 -0400 Received: from pm215 by orth.archaic.org.uk with local (Exim 4.89) (envelope-from ) id 1dpwqr-0001az-6v for qemu-devel@nongnu.org; Thu, 07 Sep 2017 14:28:13 +0100 From: Peter Maydell To: qemu-devel@nongnu.org Date: Thu, 7 Sep 2017 14:28:07 +0100 Message-Id: <1504790904-17018-15-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1504790904-17018-1-git-send-email-peter.maydell@linaro.org> References: <1504790904-17018-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 14/31] target/arm: Make PRIMASK register banked for v8M 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 PRIMASK register banked if v8M security extensions are enabled. Note that we do not yet implement the functionality of the new AIRCR.PRIS bit (which allows the effect of the NS copy of PRIMASK to be restricted). Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson Message-id: 1503414539-28762-8-git-send-email-peter.maydell@linaro.org --- target/arm/cpu.h | 2 +- hw/intc/armv7m_nvic.c | 2 +- target/arm/helper.c | 4 ++-- target/arm/machine.c | 9 +++++++-- 4 files changed, 11 insertions(+), 6 deletions(-) -- 2.7.4 diff --git a/target/arm/cpu.h b/target/arm/cpu.h index 273abc3..26ec744 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -431,7 +431,7 @@ typedef struct CPUARMState { uint32_t bfar; /* BusFault Address */ unsigned mpu_ctrl; /* MPU_CTRL */ int exception; - uint32_t primask; + uint32_t primask[2]; uint32_t faultmask; uint32_t secure; /* Is CPU in Secure state? (not guest visible) */ } v7m; diff --git a/hw/intc/armv7m_nvic.c b/hw/intc/armv7m_nvic.c index 2a41e5d..a654792 100644 --- a/hw/intc/armv7m_nvic.c +++ b/hw/intc/armv7m_nvic.c @@ -169,7 +169,7 @@ static inline int nvic_exec_prio(NVICState *s) if (env->v7m.faultmask) { running = -1; - } else if (env->v7m.primask) { + } else if (env->v7m.primask[env->v7m.secure]) { running = 0; } else if (env->v7m.basepri[env->v7m.secure] > 0) { running = env->v7m.basepri[env->v7m.secure] & nvic_gprio_mask(s); diff --git a/target/arm/helper.c b/target/arm/helper.c index 7007266..9a7ab96 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -8830,7 +8830,7 @@ 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->v7m.primask; + return env->v7m.primask[env->v7m.secure]; case 17: /* BASEPRI */ case 18: /* BASEPRI_MAX */ return env->v7m.basepri[env->v7m.secure]; @@ -8890,7 +8890,7 @@ void HELPER(v7m_msr)(CPUARMState *env, uint32_t maskreg, uint32_t val) } break; case 16: /* PRIMASK */ - env->v7m.primask = val & 1; + env->v7m.primask[env->v7m.secure] = val & 1; break; case 17: /* BASEPRI */ env->v7m.basepri[env->v7m.secure] = val & 0xff; diff --git a/target/arm/machine.c b/target/arm/machine.c index dbb432d..3c42bf5 100644 --- a/target/arm/machine.c +++ b/target/arm/machine.c @@ -103,7 +103,7 @@ static const VMStateDescription vmstate_m_faultmask_primask = { .minimum_version_id = 1, .fields = (VMStateField[]) { VMSTATE_UINT32(env.v7m.faultmask, ARMCPU), - VMSTATE_UINT32(env.v7m.primask, ARMCPU), + VMSTATE_UINT32(env.v7m.primask[M_REG_NS], ARMCPU), VMSTATE_END_OF_LIST() } }; @@ -251,6 +251,7 @@ static const VMStateDescription vmstate_m_security = { .fields = (VMStateField[]) { VMSTATE_UINT32(env.v7m.secure, ARMCPU), VMSTATE_UINT32(env.v7m.basepri[M_REG_S], ARMCPU), + VMSTATE_UINT32(env.v7m.primask[M_REG_S], ARMCPU), VMSTATE_END_OF_LIST() } }; @@ -271,9 +272,13 @@ static int get_cpsr(QEMUFile *f, void *opaque, size_t size, * 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. + * We know that this cleanup happened before v8M, so there + * is no complication with banked primask/faultmask. */ uint32_t newval = val; + assert(!arm_feature(env, ARM_FEATURE_M_SECURITY)); + newval &= (CPSR_NZCV | CPSR_Q | CPSR_IT | CPSR_GE); if (val & CPSR_T) { newval |= XPSR_T; @@ -287,7 +292,7 @@ static int get_cpsr(QEMUFile *f, void *opaque, size_t size, env->v7m.faultmask = 1; } if (val & CPSR_I) { - env->v7m.primask = 1; + env->v7m.primask[M_REG_NS] = 1; } val = newval; } From patchwork Thu Sep 7 13:28:08 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 111922 Delivered-To: patch@linaro.org Received: by 10.140.94.239 with SMTP id g102csp99531qge; Thu, 7 Sep 2017 06:33:21 -0700 (PDT) X-Google-Smtp-Source: ADKCNb4eZxMQtddsb0n5Xv+baFXGQXLVlquYCnogR3W97qLMx5/sFzIrgTdfLhCKKT1u/BRA2C8a X-Received: by 10.200.0.205 with SMTP id d13mr4060013qtg.184.1504791197527; Thu, 07 Sep 2017 06:33:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1504791197; cv=none; d=google.com; s=arc-20160816; b=moc+VgC5Tta26dSvWN5LqSL03KAA84b1/cG5exzaXRWwqs0itYQCKMU9ZiwaueMFmW 2X0L6PZchMlgCWGElmVHrkBAlqjYRbVKlgnRjYvu4pXTQOhdvuVrf+yB96A8Cp1H1GQH SRpB8W2Dw9eup7tX4ZLTkXIVzu1Q3bjORefh60WhVmCYoFigqfR/A3WUA+5SrzJyvyx3 x1e144LaAze+L0DA7qf3PVTBgjomfWqbUgU4x5l0Ur5Uk4PL3VUcNdevz9i+gAr6JaTw aaHVJni8Vt4FKiruC3JylYmJPq1FzukSDQ0YAgheZRs0DhegmNfmi+LMb9qYbsczBE2/ TuIw== 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=1kPJiCDxohXQGZdvV7C3IuGkdxEvWR0Ptbgomh7aXas=; b=kgNsOv/4yAMIcpV6ZIqAhac2yFemsnBdcGmXzSOHVsB6iN0OAU3itkzeNLxSMmcuw8 dovxkEdTNwgNkktm8uCJRX/Lod5DsWbX6e3NBcoADRTOJ3X9UQ3wN/gmv/QNDpspz1rY yF/D/drN1OEH5JlvgEAi8d3FJBEojnGDX+H5kITSiSg6H+o3mC8FKGt3KlU4AY2JruyE 1chJIlfpTO9EBYvKYwXu7m2K5RFXyJrrfwoSA3OU/k9gNXoxUxTSv/sfdiSUMR7Zl0cn L4PyAgmmpyHxq+GzfBj3SQxXi3XAxhy+gFNkgGMWwu6j8zDUKbFTaoTkZBKGej0CkjrM inIA== 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 f187si2824357qkj.80.2017.09.07.06.33.12 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 07 Sep 2017 06:33:17 -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]:40509 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dpwvf-0004Sn-0G for patch@linaro.org; Thu, 07 Sep 2017 09:33:11 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56339) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dpwqy-0000zQ-4D for qemu-devel@nongnu.org; Thu, 07 Sep 2017 09:28:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dpwqt-0007ab-5h for qemu-devel@nongnu.org; Thu, 07 Sep 2017 09:28:20 -0400 Received: from orth.archaic.org.uk ([2001:8b0:1d0::2]:37188) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dpwqs-0007a4-RV for qemu-devel@nongnu.org; Thu, 07 Sep 2017 09:28:15 -0400 Received: from pm215 by orth.archaic.org.uk with local (Exim 4.89) (envelope-from ) id 1dpwqr-0001bP-Rk for qemu-devel@nongnu.org; Thu, 07 Sep 2017 14:28:13 +0100 From: Peter Maydell To: qemu-devel@nongnu.org Date: Thu, 7 Sep 2017 14:28:08 +0100 Message-Id: <1504790904-17018-16-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1504790904-17018-1-git-send-email-peter.maydell@linaro.org> References: <1504790904-17018-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/31] target/arm: Make FAULTMASK register banked for v8M 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 FAULTMASK register banked if v8M security extensions are enabled. Note that we do not yet implement the functionality of the new AIRCR.PRIS bit (which allows the effect of the NS copy of FAULTMASK to be restricted). This patch includes the code to determine for v8M which copy of FAULTMASK should be updated on exception exit; further changes will be required to the exception exit code in general to support v8M, so this is just a small piece of that. The v8M ARM ARM introduces a notation where individual paragraphs are labelled with R (for rule) or I (for information) followed by a random group of subscript letters. In comments where we want to refer to a particular part of the manual we use this convention, which should be more stable across document revisions than using section or page numbers. Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson Message-id: 1503414539-28762-9-git-send-email-peter.maydell@linaro.org --- target/arm/cpu.h | 14 ++++++++++++-- hw/intc/armv7m_nvic.c | 9 ++++++++- target/arm/helper.c | 20 ++++++++++++++++---- target/arm/machine.c | 5 +++-- 4 files changed, 39 insertions(+), 9 deletions(-) -- 2.7.4 diff --git a/target/arm/cpu.h b/target/arm/cpu.h index 26ec744..5cf2e76 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -432,7 +432,7 @@ typedef struct CPUARMState { unsigned mpu_ctrl; /* MPU_CTRL */ int exception; uint32_t primask[2]; - uint32_t faultmask; + uint32_t faultmask[2]; uint32_t secure; /* Is CPU in Secure state? (not guest visible) */ } v7m; @@ -1442,6 +1442,16 @@ void armv7m_nvic_acknowledge_irq(void *opaque); * (Ignoring -1, this is the same as the RETTOBASE value before completion.) */ int armv7m_nvic_complete_irq(void *opaque, int irq); +/** + * armv7m_nvic_raw_execution_priority: return the raw execution priority + * @opaque: the NVIC + * + * Returns: the raw execution priority as defined by the v8M architecture. + * This is the execution priority minus the effects of AIRCR.PRIS, + * and minus any PRIMASK/FAULTMASK/BASEPRI priority boosting. + * (v8M ARM ARM I_PKLD.) + */ +int armv7m_nvic_raw_execution_priority(void *opaque); /* Interface for defining coprocessor registers. * Registers are defined in tables of arm_cp_reginfo structs @@ -2227,7 +2237,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->v7m.faultmask) { + || env->v7m.faultmask[env->v7m.secure]) { mmu_idx = ARMMMUIdx_MNegPri; } diff --git a/hw/intc/armv7m_nvic.c b/hw/intc/armv7m_nvic.c index a654792..babdc3b 100644 --- a/hw/intc/armv7m_nvic.c +++ b/hw/intc/armv7m_nvic.c @@ -167,7 +167,7 @@ static inline int nvic_exec_prio(NVICState *s) CPUARMState *env = &s->cpu->env; int running; - if (env->v7m.faultmask) { + if (env->v7m.faultmask[env->v7m.secure]) { running = -1; } else if (env->v7m.primask[env->v7m.secure]) { running = 0; @@ -187,6 +187,13 @@ bool armv7m_nvic_can_take_pending_exception(void *opaque) return nvic_exec_prio(s) > nvic_pending_prio(s); } +int armv7m_nvic_raw_execution_priority(void *opaque) +{ + NVICState *s = opaque; + + return s->exception_prio; +} + /* caller must call nvic_irq_update() after this */ static void set_prio(NVICState *s, unsigned irq, uint8_t prio) { diff --git a/target/arm/helper.c b/target/arm/helper.c index 9a7ab96..4f53ea1 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -6166,8 +6166,20 @@ 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->v7m.faultmask = 0; + /* Auto-clear FAULTMASK on return from other than NMI. + * If the security extension is implemented then this only + * happens if the raw execution priority is >= 0; the + * value of the ES bit in the exception return value indicates + * which security state's faultmask to clear. (v8M ARM ARM R_KBNF.) + */ + if (arm_feature(env, ARM_FEATURE_M_SECURITY)) { + int es = type & 1; + if (armv7m_nvic_raw_execution_priority(env->nvic) >= 0) { + env->v7m.faultmask[es] = 0; + } + } else { + env->v7m.faultmask[M_REG_NS] = 0; + } } switch (armv7m_nvic_complete_irq(env->nvic, env->v7m.exception)) { @@ -8835,7 +8847,7 @@ uint32_t HELPER(v7m_mrs)(CPUARMState *env, uint32_t reg) case 18: /* BASEPRI_MAX */ return env->v7m.basepri[env->v7m.secure]; case 19: /* FAULTMASK */ - return env->v7m.faultmask; + return env->v7m.faultmask[env->v7m.secure]; default: qemu_log_mask(LOG_GUEST_ERROR, "Attempt to read unknown special" " register %d\n", reg); @@ -8903,7 +8915,7 @@ void HELPER(v7m_msr)(CPUARMState *env, uint32_t maskreg, uint32_t val) } break; case 19: /* FAULTMASK */ - env->v7m.faultmask = val & 1; + env->v7m.faultmask[env->v7m.secure] = 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 3c42bf5..94f7279 100644 --- a/target/arm/machine.c +++ b/target/arm/machine.c @@ -102,7 +102,7 @@ static const VMStateDescription vmstate_m_faultmask_primask = { .version_id = 1, .minimum_version_id = 1, .fields = (VMStateField[]) { - VMSTATE_UINT32(env.v7m.faultmask, ARMCPU), + VMSTATE_UINT32(env.v7m.faultmask[M_REG_NS], ARMCPU), VMSTATE_UINT32(env.v7m.primask[M_REG_NS], ARMCPU), VMSTATE_END_OF_LIST() } @@ -252,6 +252,7 @@ static const VMStateDescription vmstate_m_security = { VMSTATE_UINT32(env.v7m.secure, ARMCPU), VMSTATE_UINT32(env.v7m.basepri[M_REG_S], ARMCPU), VMSTATE_UINT32(env.v7m.primask[M_REG_S], ARMCPU), + VMSTATE_UINT32(env.v7m.faultmask[M_REG_S], ARMCPU), VMSTATE_END_OF_LIST() } }; @@ -289,7 +290,7 @@ static int get_cpsr(QEMUFile *f, void *opaque, size_t size, * transferred using the vmstate_m_faultmask_primask subsection. */ if (val & CPSR_F) { - env->v7m.faultmask = 1; + env->v7m.faultmask[M_REG_NS] = 1; } if (val & CPSR_I) { env->v7m.primask[M_REG_NS] = 1; From patchwork Thu Sep 7 13:28:09 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 111944 Delivered-To: patch@linaro.org Received: by 10.140.94.239 with SMTP id g102csp120308qge; Thu, 7 Sep 2017 06:50:02 -0700 (PDT) X-Google-Smtp-Source: ADKCNb4K+76yvadyXe5SreNfVWsXLrvi9qL8h6uoQ077NSwDMaikbVVZdqRW5aPMFK9iofcO/zmi X-Received: by 10.55.170.216 with SMTP id t207mr3515485qke.232.1504792202623; Thu, 07 Sep 2017 06:50:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1504792202; cv=none; d=google.com; s=arc-20160816; b=Eg4CUlfteNNbvc+Z2oPlkU6I+MU2ft50Gz3gtzJ471hDNzDURX2aBC8TC1WgS6iVpw Q2BaK/Xsdw71HLiNcOkSzvvondbXwZixT74oP9Qloc8AxA32qJJncWANgEKL+NymA2xT B7NsJXBa9aZ6L5GYsdkdEjYfjwAo54n7v76VLMncKljpo8WpOXvoCcvQkgLu7yWVhv4y qpOoBIe8DZ/huqVjNiCQu0Nh9xv6qAwJF2PaSxRJiyp7xTfO+5dveUs/sWZfDvrXOB9z ht0LY05C1LN1X7QfE2SmJJJPjnpRe5h9QMPepLHzXKOeWgKO0JXRScvZLgl2y2saF/3T yfmA== 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=mjCZQW6MnraSBxZAld3hxACrBIM5Wz13xPqdl6Mo6oQ=; b=q5dUrE0ZAJsTTyNNz/isUWxBR5hH7PqybY/7xWa2Eluor8u6c44Dtjg85mj9JYQL6f 68NLWNBVNxKUgpm2+45n2lYezGfgRFKEJwKR+U8em7dE4eUT8dkRHc0wvqCrxuN3tRDI 6TrtDcqBQtQV0WZz+3Mpz4mJHA553bWBIm6aJgAemvrS9vxe7bFNKb1jQ5lwji3YwdTm in362Dwwjjb3fRZ+bt/s5DWXx+Ilzx39UrWfgNIEsvorJdNGXvidajDBobVLZlsGXEfd +tT1e+mdSlaw2dXKPJSMrOty85t8RXOTaRCOuVzTTS576JIpqPb9acRI8zjAG/K7nBCw /K7w== 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 q14si2901608qtg.327.2017.09.07.06.50.02 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 07 Sep 2017 06:50:02 -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]:40572 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dpxBw-0003IS-Ck for patch@linaro.org; Thu, 07 Sep 2017 09:50:00 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56463) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dpwr3-00010B-KL for qemu-devel@nongnu.org; Thu, 07 Sep 2017 09:28:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dpwqt-0007as-Qr for qemu-devel@nongnu.org; Thu, 07 Sep 2017 09:28:25 -0400 Received: from orth.archaic.org.uk ([2001:8b0:1d0::2]:37186) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dpwqt-0007Xf-Iq for qemu-devel@nongnu.org; Thu, 07 Sep 2017 09:28:15 -0400 Received: from pm215 by orth.archaic.org.uk with local (Exim 4.89) (envelope-from ) id 1dpwqs-0001bg-GR for qemu-devel@nongnu.org; Thu, 07 Sep 2017 14:28:14 +0100 From: Peter Maydell To: qemu-devel@nongnu.org Date: Thu, 7 Sep 2017 14:28:09 +0100 Message-Id: <1504790904-17018-17-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1504790904-17018-1-git-send-email-peter.maydell@linaro.org> References: <1504790904-17018-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/31] target/arm: Make CONTROL register banked for v8M 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 CONTROL register banked if v8M security extensions are enabled. Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson Message-id: 1503414539-28762-10-git-send-email-peter.maydell@linaro.org --- target/arm/cpu.h | 5 +++-- target/arm/helper.c | 21 +++++++++++---------- target/arm/machine.c | 3 ++- target/arm/translate.c | 2 +- 4 files changed, 17 insertions(+), 14 deletions(-) -- 2.7.4 diff --git a/target/arm/cpu.h b/target/arm/cpu.h index 5cf2e76..1d9eb36 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -422,7 +422,7 @@ typedef struct CPUARMState { uint32_t other_sp; uint32_t vecbase; uint32_t basepri[2]; - uint32_t control; + uint32_t control[2]; uint32_t ccr; /* Configuration and Control */ uint32_t cfsr; /* Configurable Fault Status */ uint32_t hfsr; /* HardFault Status */ @@ -1681,7 +1681,8 @@ static inline bool arm_v7m_is_handler_mode(CPUARMState *env) static inline int arm_current_el(CPUARMState *env) { if (arm_feature(env, ARM_FEATURE_M)) { - return arm_v7m_is_handler_mode(env) || !(env->v7m.control & 1); + return arm_v7m_is_handler_mode(env) || + !(env->v7m.control[env->v7m.secure] & 1); } if (is_a64(env)) { diff --git a/target/arm/helper.c b/target/arm/helper.c index 4f53ea1..aa64596 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -6048,14 +6048,15 @@ static uint32_t v7m_pop(CPUARMState *env) static void switch_v7m_sp(CPUARMState *env, bool new_spsel) { uint32_t tmp; - bool old_spsel = env->v7m.control & R_V7M_CONTROL_SPSEL_MASK; + uint32_t old_control = env->v7m.control[env->v7m.secure]; + bool old_spsel = old_control & R_V7M_CONTROL_SPSEL_MASK; if (old_spsel != new_spsel) { tmp = env->v7m.other_sp; env->v7m.other_sp = env->regs[13]; env->regs[13] = tmp; - env->v7m.control = deposit32(env->v7m.control, + env->v7m.control[env->v7m.secure] = deposit32(old_control, R_V7M_CONTROL_SPSEL_SHIFT, R_V7M_CONTROL_SPSEL_LENGTH, new_spsel); } @@ -6409,7 +6410,7 @@ void arm_v7m_cpu_do_interrupt(CPUState *cs) } lr = 0xfffffff1; - if (env->v7m.control & R_V7M_CONTROL_SPSEL_MASK) { + if (env->v7m.control[env->v7m.secure] & R_V7M_CONTROL_SPSEL_MASK) { lr |= 4; } if (!arm_v7m_is_handler_mode(env)) { @@ -8827,7 +8828,7 @@ uint32_t HELPER(v7m_mrs)(CPUARMState *env, uint32_t reg) return xpsr_read(env) & mask; break; case 20: /* CONTROL */ - return env->v7m.control; + return env->v7m.control[env->v7m.secure]; } if (el == 0) { @@ -8836,10 +8837,10 @@ uint32_t HELPER(v7m_mrs)(CPUARMState *env, uint32_t reg) switch (reg) { case 8: /* MSP */ - return (env->v7m.control & R_V7M_CONTROL_SPSEL_MASK) ? + return (env->v7m.control[env->v7m.secure] & R_V7M_CONTROL_SPSEL_MASK) ? env->v7m.other_sp : env->regs[13]; case 9: /* PSP */ - return (env->v7m.control & R_V7M_CONTROL_SPSEL_MASK) ? + return (env->v7m.control[env->v7m.secure] & R_V7M_CONTROL_SPSEL_MASK) ? env->regs[13] : env->v7m.other_sp; case 16: /* PRIMASK */ return env->v7m.primask[env->v7m.secure]; @@ -8888,14 +8889,14 @@ void HELPER(v7m_msr)(CPUARMState *env, uint32_t maskreg, uint32_t val) } break; case 8: /* MSP */ - if (env->v7m.control & R_V7M_CONTROL_SPSEL_MASK) { + if (env->v7m.control[env->v7m.secure] & R_V7M_CONTROL_SPSEL_MASK) { env->v7m.other_sp = val; } else { env->regs[13] = val; } break; case 9: /* PSP */ - if (env->v7m.control & R_V7M_CONTROL_SPSEL_MASK) { + if (env->v7m.control[env->v7m.secure] & R_V7M_CONTROL_SPSEL_MASK) { env->regs[13] = val; } else { env->v7m.other_sp = val; @@ -8926,8 +8927,8 @@ void HELPER(v7m_msr)(CPUARMState *env, uint32_t maskreg, uint32_t val) 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; - env->v7m.control |= val & R_V7M_CONTROL_NPRIV_MASK; + env->v7m.control[env->v7m.secure] &= ~R_V7M_CONTROL_NPRIV_MASK; + env->v7m.control[env->v7m.secure] |= val & R_V7M_CONTROL_NPRIV_MASK; break; default: qemu_log_mask(LOG_GUEST_ERROR, "Attempt to write unknown special" diff --git a/target/arm/machine.c b/target/arm/machine.c index 94f7279..5e379ed 100644 --- a/target/arm/machine.c +++ b/target/arm/machine.c @@ -116,7 +116,7 @@ static const VMStateDescription vmstate_m = { .fields = (VMStateField[]) { VMSTATE_UINT32(env.v7m.vecbase, ARMCPU), VMSTATE_UINT32(env.v7m.basepri[M_REG_NS], ARMCPU), - VMSTATE_UINT32(env.v7m.control, ARMCPU), + VMSTATE_UINT32(env.v7m.control[M_REG_NS], ARMCPU), VMSTATE_UINT32(env.v7m.ccr, ARMCPU), VMSTATE_UINT32(env.v7m.cfsr, ARMCPU), VMSTATE_UINT32(env.v7m.hfsr, ARMCPU), @@ -253,6 +253,7 @@ static const VMStateDescription vmstate_m_security = { VMSTATE_UINT32(env.v7m.basepri[M_REG_S], ARMCPU), VMSTATE_UINT32(env.v7m.primask[M_REG_S], ARMCPU), VMSTATE_UINT32(env.v7m.faultmask[M_REG_S], ARMCPU), + VMSTATE_UINT32(env.v7m.control[M_REG_S], ARMCPU), VMSTATE_END_OF_LIST() } }; diff --git a/target/arm/translate.c b/target/arm/translate.c index dea0a6f..6aa2d7c 100644 --- a/target/arm/translate.c +++ b/target/arm/translate.c @@ -12241,7 +12241,7 @@ void arm_cpu_dump_state(CPUState *cs, FILE *f, fprintf_function cpu_fprintf, if (xpsr & XPSR_EXCP) { mode = "handler"; } else { - if (env->v7m.control & R_V7M_CONTROL_NPRIV_MASK) { + if (env->v7m.control[env->v7m.secure] & R_V7M_CONTROL_NPRIV_MASK) { mode = "unpriv-thread"; } else { mode = "priv-thread"; From patchwork Thu Sep 7 13:28:10 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 111937 Delivered-To: patch@linaro.org Received: by 10.140.94.239 with SMTP id g102csp113123qge; Thu, 7 Sep 2017 06:43:46 -0700 (PDT) X-Google-Smtp-Source: AOwi7QDywqhPCocwBaFZ/QFF3D1wm/ygBfBbaCdpnzvHxA24uZZPim9lNFT3RMgsGp5pLls1TyVE X-Received: by 10.200.42.99 with SMTP id l32mr1011245qtl.121.1504791826718; Thu, 07 Sep 2017 06:43:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1504791826; cv=none; d=google.com; s=arc-20160816; b=NuvZBaMBkjPZjCtdjOiV0Pj64i3ccyRdmCT9mnKKAstvsm62xQCFrrxGRYlfyVZFj3 PIOiEHxLIb3Y/SwzUvaxdMarghG5eprgvV5YgWk2+F2KvCNBmVU1EbJ+8Jod4tcX+Kbc HFLKKa4KlgtBo9PCN7hF7itEv2EcKKXjxIXuprib/Yf4wyWkP8lK7a+9QUXtsXIz5xNi hCcZkoxQeLlZFgEEhC1j6m9o3/tgmdqzceLdeq5RwVE7+x5bb1JGX1EzoqJic6UKQNTo LMX1G+cvp7r6IpT9rZv1YKTrH88cwjyYOTcaSQlZ4wyMBPG8F5To3mXBDgoH6M7mvPcz M9YQ== 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=sNZL/YoyUc1w5Y3T6oHbX+Mw1EcYSf1U6KukAazJFFg=; b=thCRO/r8vYhQzNPiZ6oYd7OoyQ69c51WzYLDXCX8OgbTYSmPWdy4j4xCwExEPo63c9 0yEIgYP2S+ySQKH1X52tFURIPMlb40MPMZxhx+JFZM6KDcZB1DNdz9UAa+K2JA5akJz2 jBXI8Aoqzi8pXC9Wp3kYB6HCSgLL4VB4RSf5nkcZJuuE87Qkv72zwUQFCp1IBi2YtAtv Uj+egS3uU2LNT0QjRZOyhgabIAkCutEGd7q1qON7FNdgR8dc3u6+is6pReCL3hXj6iX7 vjDKmNib72q+fi8nlDlxXSiHnOp0tC4ybZ0od9v0k4CkonNMZA4C5aOtbFyzc+74rnuR W4Yg== 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 f34si2914757qtc.279.2017.09.07.06.43.46 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 07 Sep 2017 06:43:46 -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]:40550 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dpx5s-0006Cr-IY for patch@linaro.org; Thu, 07 Sep 2017 09:43:44 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56379) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dpwqz-0000zg-Gv for qemu-devel@nongnu.org; Thu, 07 Sep 2017 09:28:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dpwqu-0007bK-EA for qemu-devel@nongnu.org; Thu, 07 Sep 2017 09:28:21 -0400 Received: from orth.archaic.org.uk ([2001:8b0:1d0::2]:37190) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dpwqu-0007ak-63 for qemu-devel@nongnu.org; Thu, 07 Sep 2017 09:28:16 -0400 Received: from pm215 by orth.archaic.org.uk with local (Exim 4.89) (envelope-from ) id 1dpwqt-0001c8-5B for qemu-devel@nongnu.org; Thu, 07 Sep 2017 14:28:15 +0100 From: Peter Maydell To: qemu-devel@nongnu.org Date: Thu, 7 Sep 2017 14:28:10 +0100 Message-Id: <1504790904-17018-18-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1504790904-17018-1-git-send-email-peter.maydell@linaro.org> References: <1504790904-17018-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 17/31] nvic: Add NS alias SCS region 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 v8M the range 0xe002e000..0xe002efff is an alias region which for secure accesses behaves like a NonSecure access to the main SCS region. (For nonsecure accesses including when the security extension is not implemented, it is RAZ/WI.) Signed-off-by: Peter Maydell Message-id: 1503414539-28762-11-git-send-email-peter.maydell@linaro.org --- include/hw/intc/armv7m_nvic.h | 1 + hw/intc/armv7m_nvic.c | 66 ++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 66 insertions(+), 1 deletion(-) -- 2.7.4 diff --git a/include/hw/intc/armv7m_nvic.h b/include/hw/intc/armv7m_nvic.h index 1d145fb..1a4cce7 100644 --- a/include/hw/intc/armv7m_nvic.h +++ b/include/hw/intc/armv7m_nvic.h @@ -50,6 +50,7 @@ typedef struct NVICState { int exception_prio; /* group prio of the highest prio active exception */ MemoryRegion sysregmem; + MemoryRegion sysreg_ns_mem; MemoryRegion container; uint32_t num_irq; diff --git a/hw/intc/armv7m_nvic.c b/hw/intc/armv7m_nvic.c index babdc3b..2b0b328 100644 --- a/hw/intc/armv7m_nvic.c +++ b/hw/intc/armv7m_nvic.c @@ -1040,6 +1040,47 @@ static const MemoryRegionOps nvic_sysreg_ops = { .endianness = DEVICE_NATIVE_ENDIAN, }; +static MemTxResult nvic_sysreg_ns_write(void *opaque, hwaddr addr, + uint64_t value, unsigned size, + MemTxAttrs attrs) +{ + if (attrs.secure) { + /* S accesses to the alias act like NS accesses to the real region */ + attrs.secure = 0; + return nvic_sysreg_write(opaque, addr, value, size, attrs); + } else { + /* NS attrs are RAZ/WI for privileged, and BusFault for user */ + if (attrs.user) { + return MEMTX_ERROR; + } + return MEMTX_OK; + } +} + +static MemTxResult nvic_sysreg_ns_read(void *opaque, hwaddr addr, + uint64_t *data, unsigned size, + MemTxAttrs attrs) +{ + if (attrs.secure) { + /* S accesses to the alias act like NS accesses to the real region */ + attrs.secure = 0; + return nvic_sysreg_read(opaque, addr, data, size, attrs); + } else { + /* NS attrs are RAZ/WI for privileged, and BusFault for user */ + if (attrs.user) { + return MEMTX_ERROR; + } + *data = 0; + return MEMTX_OK; + } +} + +static const MemoryRegionOps nvic_sysreg_ns_ops = { + .read_with_attrs = nvic_sysreg_ns_read, + .write_with_attrs = nvic_sysreg_ns_write, + .endianness = DEVICE_NATIVE_ENDIAN, +}; + static int nvic_post_load(void *opaque, int version_id) { NVICState *s = opaque; @@ -1141,6 +1182,7 @@ static void armv7m_nvic_realize(DeviceState *dev, Error **errp) NVICState *s = NVIC(dev); SysBusDevice *systick_sbd; Error *err = NULL; + int regionlen; s->cpu = ARM_CPU(qemu_get_cpu(0)); assert(s->cpu); @@ -1173,8 +1215,23 @@ static void armv7m_nvic_realize(DeviceState *dev, Error **errp) * 0xd00..0xd3c - SCS registers * 0xd40..0xeff - Reserved or Not implemented * 0xf00 - STIR + * + * Some registers within this space are banked between security states. + * In v8M there is a second range 0xe002e000..0xe002efff which is the + * NonSecure alias SCS; secure accesses to this behave like NS accesses + * to the main SCS range, and non-secure accesses (including when + * the security extension is not implemented) are RAZ/WI. + * Note that both the main SCS range and the alias range are defined + * to be exempt from memory attribution (R_BLJT) and so the memory + * transaction attribute always matches the current CPU security + * state (attrs.secure == env->v7m.secure). In the nvic_sysreg_ns_ops + * wrappers we change attrs.secure to indicate the NS access; so + * generally code determining which banked register to use should + * use attrs.secure; code determining actual behaviour of the system + * should use env->v7m.secure. */ - memory_region_init(&s->container, OBJECT(s), "nvic", 0x1000); + regionlen = arm_feature(&s->cpu->env, ARM_FEATURE_V8) ? 0x21000 : 0x1000; + memory_region_init(&s->container, OBJECT(s), "nvic", regionlen); /* The system register region goes at the bottom of the priority * stack as it covers the whole page. */ @@ -1185,6 +1242,13 @@ static void armv7m_nvic_realize(DeviceState *dev, Error **errp) sysbus_mmio_get_region(systick_sbd, 0), 1); + if (arm_feature(&s->cpu->env, ARM_FEATURE_V8)) { + memory_region_init_io(&s->sysreg_ns_mem, OBJECT(s), + &nvic_sysreg_ns_ops, s, + "nvic_sysregs_ns", 0x1000); + memory_region_add_subregion(&s->container, 0x20000, &s->sysreg_ns_mem); + } + sysbus_init_mmio(SYS_BUS_DEVICE(dev), &s->container); } From patchwork Thu Sep 7 13:28:11 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 111928 Delivered-To: patch@linaro.org Received: by 10.140.94.239 with SMTP id g102csp102583qge; Thu, 7 Sep 2017 06:35:37 -0700 (PDT) X-Google-Smtp-Source: AOwi7QAxhjTVpn4a0m1ifGO4JeTaJGt20XCpGpOMLqhlWVMlwrAyptMpovCe6W0IOPMxJuBhlNAk X-Received: by 10.55.52.135 with SMTP id b129mr3843293qka.308.1504791337173; Thu, 07 Sep 2017 06:35:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1504791337; cv=none; d=google.com; s=arc-20160816; b=tObbkeX7DTHb29NulbgUikryd47UQHlwIbBI0tJIC8a7zDAIW2CkZOgI3Mtlx+Mhk+ eX9fCQV0oIJZSfXaZSoK3+3/+tPG2dy8q4eZlaOUbdQgqzlEm9Ye34dNQry9YcNj/yM+ 2ZEIqKmQtj8MwBbl/spraHEg6wQIUSpcuCDWrMdDDt5DYS4v2xug0awLqWd0S1c2IALC 6vRPBEHgtFoJ0/ZyhMsN3e9mXIMNEnzyss1HBop9xCCOPr3f77TW2+DBhF7q7yZYIn0m P+7EiUNqOFvIUKC7g5jadMKQdLff0oTDnNQN7kdJwgNKD5eUfolK+pxBwgKVIYtzY0pk WwQw== 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=cO3TQQf2/iQ69tJWGxW3YJHRNH99HA3OT7fSNzSBvA4=; b=QUCZdlvdReVTQDHRr85R0CiP0JIfNaVutwj66rfXbe+zbN6uo265Ll+isQ05rp02YZ c/nnETQDsQLTGT9w5KsnXNTfHnDbb6DvK8svC5oMMUdPI2uQ61T2oumLwUMd/H8xuG/o /aSyzTui5iw81+cKbPQ8t/wE+JmdMhjRsVmuT+VIfPe/TSHfkNWCb/ahaBxuP9hGc//Z midheWQBbqFQ6CtdQWnir7ByfT5cstIl5HIGCPLCXwiO3sxQ3aR/0qpNfr1MWLYZzgL6 ouLL3ptpa+FLGP8tau5DQdChfe2ANpqt0qYf5F+nbjTDyW56M0VhhrYyWLwcs6Q60JwI C7IQ== 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 g1si2973922qkd.503.2017.09.07.06.35.36 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 07 Sep 2017 06:35:37 -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]:40520 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dpwxz-0006qu-2c for patch@linaro.org; Thu, 07 Sep 2017 09:35:35 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56399) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dpwr1-0000zk-HW for qemu-devel@nongnu.org; Thu, 07 Sep 2017 09:28:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dpwqv-0007bk-3e for qemu-devel@nongnu.org; Thu, 07 Sep 2017 09:28:23 -0400 Received: from orth.archaic.org.uk ([2001:8b0:1d0::2]:37188) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dpwqu-0007a4-RD for qemu-devel@nongnu.org; Thu, 07 Sep 2017 09:28:17 -0400 Received: from pm215 by orth.archaic.org.uk with local (Exim 4.89) (envelope-from ) id 1dpwqt-0001cQ-Qq for qemu-devel@nongnu.org; Thu, 07 Sep 2017 14:28:15 +0100 From: Peter Maydell To: qemu-devel@nongnu.org Date: Thu, 7 Sep 2017 14:28:11 +0100 Message-Id: <1504790904-17018-19-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1504790904-17018-1-git-send-email-peter.maydell@linaro.org> References: <1504790904-17018-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 18/31] target/arm: Make VTOR register banked for v8M 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 VTOR register banked if v8M security extensions are enabled. Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson Message-id: 1503414539-28762-12-git-send-email-peter.maydell@linaro.org --- target/arm/cpu.h | 2 +- hw/intc/armv7m_nvic.c | 13 +++++++------ target/arm/helper.c | 2 +- target/arm/machine.c | 3 ++- 4 files changed, 11 insertions(+), 9 deletions(-) -- 2.7.4 diff --git a/target/arm/cpu.h b/target/arm/cpu.h index 1d9eb36..cf2331d 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -420,7 +420,7 @@ typedef struct CPUARMState { struct { uint32_t other_sp; - uint32_t vecbase; + uint32_t vecbase[2]; uint32_t basepri[2]; uint32_t control[2]; uint32_t ccr; /* Configuration and Control */ diff --git a/hw/intc/armv7m_nvic.c b/hw/intc/armv7m_nvic.c index 2b0b328..3a1f02d 100644 --- a/hw/intc/armv7m_nvic.c +++ b/hw/intc/armv7m_nvic.c @@ -403,7 +403,7 @@ static void set_irq_level(void *opaque, int n, int level) } } -static uint32_t nvic_readl(NVICState *s, uint32_t offset) +static uint32_t nvic_readl(NVICState *s, uint32_t offset, MemTxAttrs attrs) { ARMCPU *cpu = s->cpu; uint32_t val; @@ -441,7 +441,7 @@ static uint32_t nvic_readl(NVICState *s, uint32_t offset) /* ISRPREEMPT not implemented */ return val; case 0xd08: /* Vector Table Offset. */ - return cpu->env.v7m.vecbase; + return cpu->env.v7m.vecbase[attrs.secure]; case 0xd0c: /* Application Interrupt/Reset Control. */ return 0xfa050000 | (s->prigroup << 8); case 0xd10: /* System Control. */ @@ -617,7 +617,8 @@ static uint32_t nvic_readl(NVICState *s, uint32_t offset) } } -static void nvic_writel(NVICState *s, uint32_t offset, uint32_t value) +static void nvic_writel(NVICState *s, uint32_t offset, uint32_t value, + MemTxAttrs attrs) { ARMCPU *cpu = s->cpu; @@ -638,7 +639,7 @@ static void nvic_writel(NVICState *s, uint32_t offset, uint32_t value) } break; case 0xd08: /* Vector Table Offset. */ - cpu->env.v7m.vecbase = value & 0xffffff80; + cpu->env.v7m.vecbase[attrs.secure] = value & 0xffffff80; break; case 0xd0c: /* Application Interrupt/Reset Control. */ if ((value >> 16) == 0x05fa) { @@ -944,7 +945,7 @@ static MemTxResult nvic_sysreg_read(void *opaque, hwaddr addr, break; default: if (size == 4) { - val = nvic_readl(s, offset); + val = nvic_readl(s, offset, attrs); } else { qemu_log_mask(LOG_GUEST_ERROR, "NVIC: Bad read of size %d at offset 0x%x\n", @@ -1025,7 +1026,7 @@ static MemTxResult nvic_sysreg_write(void *opaque, hwaddr addr, return MEMTX_OK; } if (size == 4) { - nvic_writel(s, offset, value); + nvic_writel(s, offset, value, attrs); return MEMTX_OK; } qemu_log_mask(LOG_GUEST_ERROR, diff --git a/target/arm/helper.c b/target/arm/helper.c index aa64596..4685d50 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -6067,7 +6067,7 @@ static uint32_t arm_v7m_load_vector(ARMCPU *cpu) CPUState *cs = CPU(cpu); CPUARMState *env = &cpu->env; MemTxResult result; - hwaddr vec = env->v7m.vecbase + env->v7m.exception * 4; + hwaddr vec = env->v7m.vecbase[env->v7m.secure] + env->v7m.exception * 4; uint32_t addr; addr = address_space_ldl(cs->as, vec, diff --git a/target/arm/machine.c b/target/arm/machine.c index 5e379ed..923f259 100644 --- a/target/arm/machine.c +++ b/target/arm/machine.c @@ -114,7 +114,7 @@ static const VMStateDescription vmstate_m = { .minimum_version_id = 4, .needed = m_needed, .fields = (VMStateField[]) { - VMSTATE_UINT32(env.v7m.vecbase, ARMCPU), + VMSTATE_UINT32(env.v7m.vecbase[M_REG_NS], ARMCPU), VMSTATE_UINT32(env.v7m.basepri[M_REG_NS], ARMCPU), VMSTATE_UINT32(env.v7m.control[M_REG_NS], ARMCPU), VMSTATE_UINT32(env.v7m.ccr, ARMCPU), @@ -254,6 +254,7 @@ static const VMStateDescription vmstate_m_security = { VMSTATE_UINT32(env.v7m.primask[M_REG_S], ARMCPU), VMSTATE_UINT32(env.v7m.faultmask[M_REG_S], ARMCPU), VMSTATE_UINT32(env.v7m.control[M_REG_S], ARMCPU), + VMSTATE_UINT32(env.v7m.vecbase[M_REG_S], ARMCPU), VMSTATE_END_OF_LIST() } }; From patchwork Thu Sep 7 13:28:12 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 111938 Delivered-To: patch@linaro.org Received: by 10.140.94.239 with SMTP id g102csp113711qge; Thu, 7 Sep 2017 06:44:17 -0700 (PDT) X-Google-Smtp-Source: AOwi7QB0wKJC8UqB8kesoJPTNuf7DnNRheXuVdrGtyhXXykUUUBa5kx0RZbAKxaGsn/NrQgau7/O X-Received: by 10.200.25.183 with SMTP id u52mr785770qtj.102.1504791857885; Thu, 07 Sep 2017 06:44:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1504791857; cv=none; d=google.com; s=arc-20160816; b=P2emPBsViyp47jkSXNw5pMDX9vibmlWR8bgmwkzufmjX5f0U60RsVvsCOLDZ6NNAXL Dl6RNwCIQSsR372PVXDQvX7Y3PQDXwlv+SPFsP2ZFoRptje7D2wruWxIfDaiXQSWixsg jke1Duw4iVETlnD9mdn3wRmsFX/ky5IqmBP55ikRjvq5ANsDCStLrZWDvs+EP8Qw9DaD +kMxBPc5RxVyRow57TuoATPDH3WFqaQLugdASZrL41g6J6HNa5q6BmXr28XwYDRjX0rw ihLN7hAtzpt3pBrmQ7zIBV8HBVwKqLGGqa1kIqttAsSdGb3MfiIjJeZET1A5aNU8KFK3 6opg== 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=k38GdZqu674Sor1HY8ufWELCQF12Kf+Tl9gMBsk6ZnI=; b=mo+82oPHKAZH9hgXlV0szUGD0e7P/MG9JcykeUNpoRa2I4HPR2eNEMbppoKbTMOI42 sahgk3lC6JEm84LEn80GdTCbaTOpsliZUht2OaLlEimT0FS3fPWQ8SO8kYD1YagdBO2D 1yFYKOr0px2y8If7GzYME3ceC7gtwhHAPAMIqsh5FNvw/8sKlpHS8VleK32URAGNI47g 4bwyVfhoY+G3Lc6cxnyiyLWNmeY7DnULVFi1L1qG/CiR1irVfotjFJl6x0IEsQqt+JSD z91cuob7j9u0dpsn5BWHpSrI77Ba+AKovZzk19GX6o/G3ri65AY4SNrmyWfC/XTbGbn6 sqlQ== 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 v15si2896048qkl.378.2017.09.07.06.44.17 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 07 Sep 2017 06:44:17 -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]:40551 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dpx6N-0006Oc-Nx for patch@linaro.org; Thu, 07 Sep 2017 09:44:15 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56503) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dpwr7-00011x-3u for qemu-devel@nongnu.org; Thu, 07 Sep 2017 09:28:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dpwqv-0007cE-Ov for qemu-devel@nongnu.org; Thu, 07 Sep 2017 09:28:29 -0400 Received: from orth.archaic.org.uk ([2001:8b0:1d0::2]:37192) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dpwqv-0007bf-Gv for qemu-devel@nongnu.org; Thu, 07 Sep 2017 09:28:17 -0400 Received: from pm215 by orth.archaic.org.uk with local (Exim 4.89) (envelope-from ) id 1dpwqu-0001cw-Hw for qemu-devel@nongnu.org; Thu, 07 Sep 2017 14:28:16 +0100 From: Peter Maydell To: qemu-devel@nongnu.org Date: Thu, 7 Sep 2017 14:28:12 +0100 Message-Id: <1504790904-17018-20-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1504790904-17018-1-git-send-email-peter.maydell@linaro.org> References: <1504790904-17018-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/31] target/arm: Make MPU_MAIR0, MPU_MAIR1 registers banked for v8M 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 MPU registers MPU_MAIR0 and MPU_MAIR1 banked if v8M security extensions are enabled. Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson Message-id: 1503414539-28762-13-git-send-email-peter.maydell@linaro.org --- target/arm/cpu.h | 4 ++-- hw/intc/armv7m_nvic.c | 8 ++++---- target/arm/cpu.c | 6 ++++-- target/arm/machine.c | 6 ++++-- 4 files changed, 14 insertions(+), 10 deletions(-) -- 2.7.4 diff --git a/target/arm/cpu.h b/target/arm/cpu.h index cf2331d..42a6cb2 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -545,8 +545,8 @@ typedef struct CPUARMState { */ uint32_t *rbar; uint32_t *rlar; - uint32_t mair0; - uint32_t mair1; + uint32_t mair0[2]; + uint32_t mair1[2]; } pmsav8; void *nvic; diff --git a/hw/intc/armv7m_nvic.c b/hw/intc/armv7m_nvic.c index 3a1f02d..e98eb95 100644 --- a/hw/intc/armv7m_nvic.c +++ b/hw/intc/armv7m_nvic.c @@ -604,12 +604,12 @@ static uint32_t nvic_readl(NVICState *s, uint32_t offset, MemTxAttrs attrs) if (!arm_feature(&cpu->env, ARM_FEATURE_V8)) { goto bad_offset; } - return cpu->env.pmsav8.mair0; + return cpu->env.pmsav8.mair0[attrs.secure]; case 0xdc4: /* MPU_MAIR1 */ if (!arm_feature(&cpu->env, ARM_FEATURE_V8)) { goto bad_offset; } - return cpu->env.pmsav8.mair1; + return cpu->env.pmsav8.mair1[attrs.secure]; default: bad_offset: qemu_log_mask(LOG_GUEST_ERROR, "NVIC: Bad read offset 0x%x\n", offset); @@ -826,7 +826,7 @@ static void nvic_writel(NVICState *s, uint32_t offset, uint32_t value, } if (cpu->pmsav7_dregion) { /* Register is RES0 if no MPU regions are implemented */ - cpu->env.pmsav8.mair0 = value; + cpu->env.pmsav8.mair0[attrs.secure] = value; } /* We don't need to do anything else because memory attributes * only affect cacheability, and we don't implement caching. @@ -838,7 +838,7 @@ static void nvic_writel(NVICState *s, uint32_t offset, uint32_t value, } if (cpu->pmsav7_dregion) { /* Register is RES0 if no MPU regions are implemented */ - cpu->env.pmsav8.mair1 = value; + cpu->env.pmsav8.mair1[attrs.secure] = value; } /* We don't need to do anything else because memory attributes * only affect cacheability, and we don't implement caching. diff --git a/target/arm/cpu.c b/target/arm/cpu.c index ae866be..7b4acc0 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -249,8 +249,10 @@ static void arm_cpu_reset(CPUState *s) } } env->pmsav7.rnr = 0; - env->pmsav8.mair0 = 0; - env->pmsav8.mair1 = 0; + env->pmsav8.mair0[M_REG_NS] = 0; + env->pmsav8.mair0[M_REG_S] = 0; + env->pmsav8.mair1[M_REG_NS] = 0; + env->pmsav8.mair1[M_REG_S] = 0; } set_flush_to_zero(1, &env->vfp.standard_fp_status); diff --git a/target/arm/machine.c b/target/arm/machine.c index 923f259..80942d6 100644 --- a/target/arm/machine.c +++ b/target/arm/machine.c @@ -229,8 +229,8 @@ static const VMStateDescription vmstate_pmsav8 = { vmstate_info_uint32, uint32_t), VMSTATE_VARRAY_UINT32(env.pmsav8.rlar, ARMCPU, pmsav7_dregion, 0, vmstate_info_uint32, uint32_t), - VMSTATE_UINT32(env.pmsav8.mair0, ARMCPU), - VMSTATE_UINT32(env.pmsav8.mair1, ARMCPU), + VMSTATE_UINT32(env.pmsav8.mair0[M_REG_NS], ARMCPU), + VMSTATE_UINT32(env.pmsav8.mair1[M_REG_NS], ARMCPU), VMSTATE_END_OF_LIST() } }; @@ -255,6 +255,8 @@ static const VMStateDescription vmstate_m_security = { VMSTATE_UINT32(env.v7m.faultmask[M_REG_S], ARMCPU), VMSTATE_UINT32(env.v7m.control[M_REG_S], ARMCPU), VMSTATE_UINT32(env.v7m.vecbase[M_REG_S], ARMCPU), + VMSTATE_UINT32(env.pmsav8.mair0[M_REG_S], ARMCPU), + VMSTATE_UINT32(env.pmsav8.mair1[M_REG_S], ARMCPU), VMSTATE_END_OF_LIST() } }; From patchwork Thu Sep 7 13:28:13 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 111936 Delivered-To: patch@linaro.org Received: by 10.140.94.239 with SMTP id g102csp111969qge; Thu, 7 Sep 2017 06:42:47 -0700 (PDT) X-Google-Smtp-Source: ADKCNb5N03zyr4qfkUB5M0LPQTAY1oSmQjR6eBl0ZzAaelK0U8smgZ2sa03Obglp5Tmb/Zz0Fj/Y X-Received: by 10.200.42.22 with SMTP id k22mr3867461qtk.323.1504791767762; Thu, 07 Sep 2017 06:42:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1504791767; cv=none; d=google.com; s=arc-20160816; b=cxQTUJDU2bFwnEkfEPQOr6E/YXpJ5mhbVBJfeAKeZ5x0LK182FgitZU79WgNPjRZ+E XBK4pkP9xv/RgKOYYzyiy0xrJF/GO5rb5sgD23VBEJeuI61poLeYcx3huhNhd5qJWD0z mkwhgw1dxTQTU7vI0HhQE6jZhczrI3xaCZW5cYEV+JBBgvl3pbkEdlW2T+4+y/vOlvQZ +VPFR2kzUKX7nE0aHkbQ7bxtlDnvwMHsISb920QsUsVs+nOS8NVOXMtokKqTblwBwNkg BUbAy+wDCEq0cIYyPz7QlzaDviaox4XHgyO8jtWj3yFnnk81tM+26iGGEVkrVK/zgQ5X e9jQ== 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=jXu1axaD9rCLAgXw6aeMkRE33Dmxp14O4RG2uqezy34=; b=u2w9coOZzrglxflPgzbAK1yCPKsTpsRPWiOHZjAsh1QXtnIAH7EaM5lp6h2RMu/E/m iyod8sJUWbh0l4/aSZDoToNwSWMZeLPNzjoB2ZJRfiA8+vK89iM+mBGr/29C+lfaPvrT 1L0V1hRPVqVjvenATTXk7fkWhOkB5Dxh47qMztQmi8IsAxdQO4Ub2SpUKhC/z4FA2GRK lgQt/MDAGfVMrksK7+YE2vYRTSDz7Az/1cLvNU4D3xaE/ZC0GowgsVQebn7PRfqWP+ut arweYdUWtgNrYalKrGkH42/Ln0gg8F1r8Nd/bNS2JlAVs0QBaXSqgt2rXL++nOtVSToW xInw== 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 g124si2749501qkc.446.2017.09.07.06.42.47 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 07 Sep 2017 06:42: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]:40544 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dpx4v-0004i8-HN for patch@linaro.org; Thu, 07 Sep 2017 09:42:45 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56417) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dpwr2-0000zu-CH for qemu-devel@nongnu.org; Thu, 07 Sep 2017 09:28:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dpwqw-0007dC-VP for qemu-devel@nongnu.org; Thu, 07 Sep 2017 09:28:24 -0400 Received: from orth.archaic.org.uk ([2001:8b0:1d0::2]:37192) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dpwqw-0007bf-ML for qemu-devel@nongnu.org; Thu, 07 Sep 2017 09:28:18 -0400 Received: from pm215 by orth.archaic.org.uk with local (Exim 4.89) (envelope-from ) id 1dpwqv-0001dG-9E for qemu-devel@nongnu.org; Thu, 07 Sep 2017 14:28:17 +0100 From: Peter Maydell To: qemu-devel@nongnu.org Date: Thu, 7 Sep 2017 14:28:13 +0100 Message-Id: <1504790904-17018-21-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1504790904-17018-1-git-send-email-peter.maydell@linaro.org> References: <1504790904-17018-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/31] target/arm: Make MPU_RBAR, MPU_RLAR banked for v8M 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 MPU registers MPU_MAIR0 and MPU_MAIR1 banked if v8M security extensions are enabled. We can freely add more items to vmstate_m_security without breaking migration compatibility, because no CPU currently has the ARM_FEATURE_M_SECURITY bit enabled and so this subsection is not yet used by anything. Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson Message-id: 1503414539-28762-14-git-send-email-peter.maydell@linaro.org --- target/arm/cpu.h | 4 ++-- hw/intc/armv7m_nvic.c | 8 ++++---- target/arm/cpu.c | 26 ++++++++++++++++++++------ target/arm/helper.c | 11 ++++++----- target/arm/machine.c | 12 ++++++++---- 5 files changed, 40 insertions(+), 21 deletions(-) -- 2.7.4 diff --git a/target/arm/cpu.h b/target/arm/cpu.h index 42a6cb2..d385ef2 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -543,8 +543,8 @@ typedef struct CPUARMState { * pmsav7.rnr (region number register) * pmsav7_dregion (number of configured regions) */ - uint32_t *rbar; - uint32_t *rlar; + uint32_t *rbar[2]; + uint32_t *rlar[2]; uint32_t mair0[2]; uint32_t mair1[2]; } pmsav8; diff --git a/hw/intc/armv7m_nvic.c b/hw/intc/armv7m_nvic.c index e98eb95..9ced7af 100644 --- a/hw/intc/armv7m_nvic.c +++ b/hw/intc/armv7m_nvic.c @@ -564,7 +564,7 @@ static uint32_t nvic_readl(NVICState *s, uint32_t offset, MemTxAttrs attrs) if (region >= cpu->pmsav7_dregion) { return 0; } - return cpu->env.pmsav8.rbar[region]; + return cpu->env.pmsav8.rbar[attrs.secure][region]; } if (region >= cpu->pmsav7_dregion) { @@ -591,7 +591,7 @@ static uint32_t nvic_readl(NVICState *s, uint32_t offset, MemTxAttrs attrs) if (region >= cpu->pmsav7_dregion) { return 0; } - return cpu->env.pmsav8.rlar[region]; + return cpu->env.pmsav8.rlar[attrs.secure][region]; } if (region >= cpu->pmsav7_dregion) { @@ -756,7 +756,7 @@ static void nvic_writel(NVICState *s, uint32_t offset, uint32_t value, if (region >= cpu->pmsav7_dregion) { return; } - cpu->env.pmsav8.rbar[region] = value; + cpu->env.pmsav8.rbar[attrs.secure][region] = value; tlb_flush(CPU(cpu)); return; } @@ -806,7 +806,7 @@ static void nvic_writel(NVICState *s, uint32_t offset, uint32_t value, if (region >= cpu->pmsav7_dregion) { return; } - cpu->env.pmsav8.rlar[region] = value; + cpu->env.pmsav8.rlar[attrs.secure][region] = value; tlb_flush(CPU(cpu)); return; } diff --git a/target/arm/cpu.c b/target/arm/cpu.c index 7b4acc0..40ec445 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -235,10 +235,20 @@ static void arm_cpu_reset(CPUState *s) if (arm_feature(env, ARM_FEATURE_PMSA)) { if (cpu->pmsav7_dregion > 0) { if (arm_feature(env, ARM_FEATURE_V8)) { - memset(env->pmsav8.rbar, 0, - sizeof(*env->pmsav8.rbar) * cpu->pmsav7_dregion); - memset(env->pmsav8.rlar, 0, - sizeof(*env->pmsav8.rlar) * cpu->pmsav7_dregion); + memset(env->pmsav8.rbar[M_REG_NS], 0, + sizeof(*env->pmsav8.rbar[M_REG_NS]) + * cpu->pmsav7_dregion); + memset(env->pmsav8.rlar[M_REG_NS], 0, + sizeof(*env->pmsav8.rlar[M_REG_NS]) + * cpu->pmsav7_dregion); + if (arm_feature(env, ARM_FEATURE_M_SECURITY)) { + memset(env->pmsav8.rbar[M_REG_S], 0, + sizeof(*env->pmsav8.rbar[M_REG_S]) + * cpu->pmsav7_dregion); + memset(env->pmsav8.rlar[M_REG_S], 0, + sizeof(*env->pmsav8.rlar[M_REG_S]) + * cpu->pmsav7_dregion); + } } else if (arm_feature(env, ARM_FEATURE_V7)) { memset(env->pmsav7.drbar, 0, sizeof(*env->pmsav7.drbar) * cpu->pmsav7_dregion); @@ -825,8 +835,12 @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp) if (nr) { if (arm_feature(env, ARM_FEATURE_V8)) { /* PMSAv8 */ - env->pmsav8.rbar = g_new0(uint32_t, nr); - env->pmsav8.rlar = g_new0(uint32_t, nr); + env->pmsav8.rbar[M_REG_NS] = g_new0(uint32_t, nr); + env->pmsav8.rlar[M_REG_NS] = g_new0(uint32_t, nr); + if (arm_feature(env, ARM_FEATURE_M_SECURITY)) { + env->pmsav8.rbar[M_REG_S] = g_new0(uint32_t, nr); + env->pmsav8.rlar[M_REG_S] = g_new0(uint32_t, nr); + } } else { env->pmsav7.drbar = g_new0(uint32_t, nr); env->pmsav7.drsr = g_new0(uint32_t, nr); diff --git a/target/arm/helper.c b/target/arm/helper.c index 4685d50..bcbd087 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -8437,6 +8437,7 @@ static bool get_phys_addr_pmsav8(CPUARMState *env, uint32_t address, { ARMCPU *cpu = arm_env_get_cpu(env); bool is_user = regime_is_user(env, mmu_idx); + uint32_t secure = regime_is_secure(env, mmu_idx); int n; int matchregion = -1; bool hit = false; @@ -8463,10 +8464,10 @@ static bool get_phys_addr_pmsav8(CPUARMState *env, uint32_t address, * with bits [4:0] all zeroes, but the limit address is bits * [31:5] from the register with bits [4:0] all ones. */ - uint32_t base = env->pmsav8.rbar[n] & ~0x1f; - uint32_t limit = env->pmsav8.rlar[n] | 0x1f; + uint32_t base = env->pmsav8.rbar[secure][n] & ~0x1f; + uint32_t limit = env->pmsav8.rlar[secure][n] | 0x1f; - if (!(env->pmsav8.rlar[n] & 0x1)) { + if (!(env->pmsav8.rlar[secure][n] & 0x1)) { /* Region disabled */ continue; } @@ -8515,8 +8516,8 @@ static bool get_phys_addr_pmsav8(CPUARMState *env, uint32_t address, /* hit using the background region */ get_phys_addr_pmsav7_default(env, mmu_idx, address, prot); } else { - uint32_t ap = extract32(env->pmsav8.rbar[matchregion], 1, 2); - uint32_t xn = extract32(env->pmsav8.rbar[matchregion], 0, 1); + uint32_t ap = extract32(env->pmsav8.rbar[secure][matchregion], 1, 2); + uint32_t xn = extract32(env->pmsav8.rbar[secure][matchregion], 0, 1); if (m_is_system_region(env, address)) { /* System space is always execute never */ diff --git a/target/arm/machine.c b/target/arm/machine.c index 80942d6..0017ea0 100644 --- a/target/arm/machine.c +++ b/target/arm/machine.c @@ -225,10 +225,10 @@ static const VMStateDescription vmstate_pmsav8 = { .minimum_version_id = 1, .needed = pmsav8_needed, .fields = (VMStateField[]) { - VMSTATE_VARRAY_UINT32(env.pmsav8.rbar, ARMCPU, pmsav7_dregion, 0, - vmstate_info_uint32, uint32_t), - VMSTATE_VARRAY_UINT32(env.pmsav8.rlar, ARMCPU, pmsav7_dregion, 0, - vmstate_info_uint32, uint32_t), + VMSTATE_VARRAY_UINT32(env.pmsav8.rbar[M_REG_NS], ARMCPU, pmsav7_dregion, + 0, vmstate_info_uint32, uint32_t), + VMSTATE_VARRAY_UINT32(env.pmsav8.rlar[M_REG_NS], ARMCPU, pmsav7_dregion, + 0, vmstate_info_uint32, uint32_t), VMSTATE_UINT32(env.pmsav8.mair0[M_REG_NS], ARMCPU), VMSTATE_UINT32(env.pmsav8.mair1[M_REG_NS], ARMCPU), VMSTATE_END_OF_LIST() @@ -257,6 +257,10 @@ static const VMStateDescription vmstate_m_security = { VMSTATE_UINT32(env.v7m.vecbase[M_REG_S], ARMCPU), VMSTATE_UINT32(env.pmsav8.mair0[M_REG_S], ARMCPU), VMSTATE_UINT32(env.pmsav8.mair1[M_REG_S], ARMCPU), + VMSTATE_VARRAY_UINT32(env.pmsav8.rbar[M_REG_S], ARMCPU, pmsav7_dregion, + 0, vmstate_info_uint32, uint32_t), + VMSTATE_VARRAY_UINT32(env.pmsav8.rlar[M_REG_S], ARMCPU, pmsav7_dregion, + 0, vmstate_info_uint32, uint32_t), VMSTATE_END_OF_LIST() } }; From patchwork Thu Sep 7 13:28:14 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 111932 Delivered-To: patch@linaro.org Received: by 10.140.94.239 with SMTP id g102csp108643qge; Thu, 7 Sep 2017 06:40:05 -0700 (PDT) X-Google-Smtp-Source: ADKCNb4dH4j2jhbhQbUx/hyQ55LF68GapelerIvD+ZejF47vwwzuvENyYlrjWy4XbWx/GW0XLwjo X-Received: by 10.55.152.198 with SMTP id a189mr3552388qke.190.1504791605098; Thu, 07 Sep 2017 06:40:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1504791605; cv=none; d=google.com; s=arc-20160816; b=i/8P6Pl1gBIOD3ArjYoRZEapRrOoszX8GaE1hz7GirEwP2DsCvFIMvW9+WSVZOK4Xm OLUhquEj7Cew+/PfWD39MIEgW2p+7UOWwySKvdT71DznWeE7DQO6GVYNgjgyWXzKkP0C mcNco4AlDgh1CyW+V+DG2A4OOZw9a4XaUZFYlLspuh0m2835nGHtRK7MWdedBqz9mPDK 75sctEZLQcaw4BKFuTy7CRSQ7HDQoulJzeziBSmfjGF25I1Whg+44qt+6cJwYcLMh6FO vO/QjcSvuswKIkzu+LNYNaUSQQEFRVtajIfGD7BE62zY5zGZq3K2LoRczUur1T/yy0MS 3LgQ== 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=3BUiI8zMKGN8sHPSc3k7ETWuL/BbrA90EjK+1dzwOmU=; b=MwIsr/Yshkw98iPbpI3+9+1/MxJ0mDNqNXCpKhmwYUr6s2EuPtouogG0muMTM7kn6J Z3ZxIW63ySVtZSJtK4W4bCjfrCZC3Tiza7pBrU2nw4D9rwkXgGfklN6k8q4giNC7eGyn pO4n5A+H0qgroOEr6JMilX2XlMK0ORblFA1SRS+UUQ2neh57TEuTZRZHewQJIUn6140V WLafsaRchLjDM1e0X6WpjlWHa7shPvB8imwhAnwjUfP6l6o6oZor/iXMt5mlpwQbQ4ob 16ITGCMg2t0pn8rYAsTKha5X9o1PmNAgrdMoFzMauDf4hrvdcTrB++Mh3Hc4jDrnILR8 uhIg== 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 q14si2882256qtg.327.2017.09.07.06.40.04 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 07 Sep 2017 06:40: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]:40536 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dpx2I-0002Ux-Na for patch@linaro.org; Thu, 07 Sep 2017 09:40:02 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56434) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dpwr2-000100-PF for qemu-devel@nongnu.org; Thu, 07 Sep 2017 09:28:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dpwqx-0007dU-F0 for qemu-devel@nongnu.org; Thu, 07 Sep 2017 09:28:24 -0400 Received: from orth.archaic.org.uk ([2001:8b0:1d0::2]:37194) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dpwqx-0007cY-3q for qemu-devel@nongnu.org; Thu, 07 Sep 2017 09:28:19 -0400 Received: from pm215 by orth.archaic.org.uk with local (Exim 4.89) (envelope-from ) id 1dpwqw-0001dm-1C for qemu-devel@nongnu.org; Thu, 07 Sep 2017 14:28:18 +0100 From: Peter Maydell To: qemu-devel@nongnu.org Date: Thu, 7 Sep 2017 14:28:14 +0100 Message-Id: <1504790904-17018-22-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1504790904-17018-1-git-send-email-peter.maydell@linaro.org> References: <1504790904-17018-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/31] target/arm: Make MPU_RNR register banked for v8M 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 MPU_RNR register banked if v8M security extensions are enabled. Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson Message-id: 1503414539-28762-15-git-send-email-peter.maydell@linaro.org --- target/arm/cpu.h | 2 +- hw/intc/armv7m_nvic.c | 18 +++++++++--------- target/arm/cpu.c | 3 ++- target/arm/helper.c | 6 +++--- target/arm/machine.c | 13 +++++++++++-- 5 files changed, 26 insertions(+), 16 deletions(-) -- 2.7.4 diff --git a/target/arm/cpu.h b/target/arm/cpu.h index d385ef2..425adc3 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -533,7 +533,7 @@ typedef struct CPUARMState { uint32_t *drbar; uint32_t *drsr; uint32_t *dracr; - uint32_t rnr; + uint32_t rnr[2]; } pmsav7; /* PMSAv8 MPU */ diff --git a/hw/intc/armv7m_nvic.c b/hw/intc/armv7m_nvic.c index 9ced7af..c3c214c 100644 --- a/hw/intc/armv7m_nvic.c +++ b/hw/intc/armv7m_nvic.c @@ -543,13 +543,13 @@ static uint32_t nvic_readl(NVICState *s, uint32_t offset, MemTxAttrs attrs) case 0xd94: /* MPU_CTRL */ return cpu->env.v7m.mpu_ctrl; case 0xd98: /* MPU_RNR */ - return cpu->env.pmsav7.rnr; + return cpu->env.pmsav7.rnr[attrs.secure]; case 0xd9c: /* MPU_RBAR */ case 0xda4: /* MPU_RBAR_A1 */ case 0xdac: /* MPU_RBAR_A2 */ case 0xdb4: /* MPU_RBAR_A3 */ { - int region = cpu->env.pmsav7.rnr; + int region = cpu->env.pmsav7.rnr[attrs.secure]; if (arm_feature(&cpu->env, ARM_FEATURE_V8)) { /* PMSAv8M handling of the aliases is different from v7M: @@ -577,7 +577,7 @@ static uint32_t nvic_readl(NVICState *s, uint32_t offset, MemTxAttrs attrs) case 0xdb0: /* MPU_RASR_A2 (v7M), MPU_RLAR_A2 (v8M) */ case 0xdb8: /* MPU_RASR_A3 (v7M), MPU_RLAR_A3 (v8M) */ { - int region = cpu->env.pmsav7.rnr; + int region = cpu->env.pmsav7.rnr[attrs.secure]; if (arm_feature(&cpu->env, ARM_FEATURE_V8)) { /* PMSAv8M handling of the aliases is different from v7M: @@ -731,7 +731,7 @@ static void nvic_writel(NVICState *s, uint32_t offset, uint32_t value, PRIu32 "/%" PRIu32 "\n", value, cpu->pmsav7_dregion); } else { - cpu->env.pmsav7.rnr = value; + cpu->env.pmsav7.rnr[attrs.secure] = value; } break; case 0xd9c: /* MPU_RBAR */ @@ -749,7 +749,7 @@ static void nvic_writel(NVICState *s, uint32_t offset, uint32_t value, */ int aliasno = (offset - 0xd9c) / 8; /* 0..3 */ - region = cpu->env.pmsav7.rnr; + region = cpu->env.pmsav7.rnr[attrs.secure]; if (aliasno) { region = deposit32(region, 0, 2, aliasno); } @@ -772,9 +772,9 @@ static void nvic_writel(NVICState *s, uint32_t offset, uint32_t value, region, cpu->pmsav7_dregion); return; } - cpu->env.pmsav7.rnr = region; + cpu->env.pmsav7.rnr[attrs.secure] = region; } else { - region = cpu->env.pmsav7.rnr; + region = cpu->env.pmsav7.rnr[attrs.secure]; } if (region >= cpu->pmsav7_dregion) { @@ -790,7 +790,7 @@ static void nvic_writel(NVICState *s, uint32_t offset, uint32_t value, case 0xdb0: /* MPU_RASR_A2 (v7M), MPU_RLAR_A2 (v8M) */ case 0xdb8: /* MPU_RASR_A3 (v7M), MPU_RLAR_A3 (v8M) */ { - int region = cpu->env.pmsav7.rnr; + int region = cpu->env.pmsav7.rnr[attrs.secure]; if (arm_feature(&cpu->env, ARM_FEATURE_V8)) { /* PMSAv8M handling of the aliases is different from v7M: @@ -799,7 +799,7 @@ static void nvic_writel(NVICState *s, uint32_t offset, uint32_t value, */ int aliasno = (offset - 0xd9c) / 8; /* 0..3 */ - region = cpu->env.pmsav7.rnr; + region = cpu->env.pmsav7.rnr[attrs.secure]; if (aliasno) { region = deposit32(region, 0, 2, aliasno); } diff --git a/target/arm/cpu.c b/target/arm/cpu.c index 40ec445..b7f5ec2 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -258,7 +258,8 @@ static void arm_cpu_reset(CPUState *s) sizeof(*env->pmsav7.dracr) * cpu->pmsav7_dregion); } } - env->pmsav7.rnr = 0; + env->pmsav7.rnr[M_REG_NS] = 0; + env->pmsav7.rnr[M_REG_S] = 0; env->pmsav8.mair0[M_REG_NS] = 0; env->pmsav8.mair0[M_REG_S] = 0; env->pmsav8.mair1[M_REG_NS] = 0; diff --git a/target/arm/helper.c b/target/arm/helper.c index bcbd087..4db191e 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -2385,7 +2385,7 @@ static uint64_t pmsav7_read(CPUARMState *env, const ARMCPRegInfo *ri) return 0; } - u32p += env->pmsav7.rnr; + u32p += env->pmsav7.rnr[M_REG_NS]; return *u32p; } @@ -2399,7 +2399,7 @@ static void pmsav7_write(CPUARMState *env, const ARMCPRegInfo *ri, return; } - u32p += env->pmsav7.rnr; + u32p += env->pmsav7.rnr[M_REG_NS]; tlb_flush(CPU(cpu)); /* Mappings may have changed - purge! */ *u32p = value; } @@ -2442,7 +2442,7 @@ static const ARMCPRegInfo pmsav7_cp_reginfo[] = { .resetfn = arm_cp_reset_ignore }, { .name = "RGNR", .cp = 15, .crn = 6, .opc1 = 0, .crm = 2, .opc2 = 0, .access = PL1_RW, - .fieldoffset = offsetof(CPUARMState, pmsav7.rnr), + .fieldoffset = offsetof(CPUARMState, pmsav7.rnr[M_REG_NS]), .writefn = pmsav7_rgnr_write, .resetfn = arm_cp_reset_ignore }, REGINFO_SENTINEL diff --git a/target/arm/machine.c b/target/arm/machine.c index 0017ea0..7f894e5 100644 --- a/target/arm/machine.c +++ b/target/arm/machine.c @@ -167,7 +167,7 @@ static bool pmsav7_rgnr_vmstate_validate(void *opaque, int version_id) { ARMCPU *cpu = opaque; - return cpu->env.pmsav7.rnr < cpu->pmsav7_dregion; + return cpu->env.pmsav7.rnr[M_REG_NS] < cpu->pmsav7_dregion; } static const VMStateDescription vmstate_pmsav7 = { @@ -205,7 +205,7 @@ static const VMStateDescription vmstate_pmsav7_rnr = { .minimum_version_id = 1, .needed = pmsav7_rnr_needed, .fields = (VMStateField[]) { - VMSTATE_UINT32(env.pmsav7.rnr, ARMCPU), + VMSTATE_UINT32(env.pmsav7.rnr[M_REG_NS], ARMCPU), VMSTATE_END_OF_LIST() } }; @@ -235,6 +235,13 @@ static const VMStateDescription vmstate_pmsav8 = { } }; +static bool s_rnr_vmstate_validate(void *opaque, int version_id) +{ + ARMCPU *cpu = opaque; + + return cpu->env.pmsav7.rnr[M_REG_S] < cpu->pmsav7_dregion; +} + static bool m_security_needed(void *opaque) { ARMCPU *cpu = opaque; @@ -261,6 +268,8 @@ static const VMStateDescription vmstate_m_security = { 0, vmstate_info_uint32, uint32_t), VMSTATE_VARRAY_UINT32(env.pmsav8.rlar[M_REG_S], ARMCPU, pmsav7_dregion, 0, vmstate_info_uint32, uint32_t), + VMSTATE_UINT32(env.pmsav7.rnr[M_REG_S], ARMCPU), + VMSTATE_VALIDATE("secure MPU_RNR is valid", s_rnr_vmstate_validate), VMSTATE_END_OF_LIST() } }; From patchwork Thu Sep 7 13:28:15 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 111935 Delivered-To: patch@linaro.org Received: by 10.140.94.239 with SMTP id g102csp111892qge; Thu, 7 Sep 2017 06:42:44 -0700 (PDT) X-Google-Smtp-Source: ADKCNb5v9WWKs/fwHflKF3iSZ0kDiWo+aVlcwX06K8ndBRfSudr6rPGmzKq8uJuhaU93rDhJ+oTC X-Received: by 10.55.74.72 with SMTP id x69mr3605386qka.84.1504791764256; Thu, 07 Sep 2017 06:42:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1504791764; cv=none; d=google.com; s=arc-20160816; b=izJCJ2j4R+21oq8Fzii01d9qqiSkTvMrWGwfHozJN6/feJXH3/iR2oj47f7mrnhe0T ZMnrhR/X6vt8yFPAhbfVTlQ59Faqaw0CntmUuDevTNIxj9RMmiWfnHHE42/xIiTdzUXj leQC1MZ8ck1dbc9u8pjO3f4iTbQNsy0MAbkjh9+nyCCjPXG9Xm0UA5D3FOnWRtCU0JyR hptZ7APOIOT9OO6ukuRY7HafY9AUEv4CSB2STYpVXbZI5tbN6elP74j4JJhU8I04crqp Y8QfIN9oFtH1ee5EI5aO73/cBYWFAsBCgKRsE2OqNJGSuivOHcCUCInSuiKcurty37Vt q73w== 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=aio2EjLpVhxtZlXRg/RrPoIUUoHPaQvj1YbqenINKuE=; b=MEAtZC6Ibj3vjtoZhXEirmzdNpPpLtw364qUd5FAV/MeJTPEbzG1+O+Yme+6fGALhe 9oo5XaOo9VXZR8zlDiHmZxx1K0OkECxOP3CzWDxgK9gME8Ey6BEzVg0eQ+KAcPf/1dVm l8N3JqQJJLuxXh9cwJKpsv+KzruG/L20eNbq00brE9v+poo9NKwVrJ3erfcgwa7+8lqa /z8GJxV34sH9Tk2djEYS1+syySc8c7Hfyy6K4Zh/+UmgGR8rjyJ2dV4GmPqUX1q8PPMd x3c7D//IXrPHOoejHh7XXeOdy0bDz3kePuMA3oBiQP2eoTmKZDxFf6dX/onUQVJfK+0o J85Q== 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 t1si2913523qte.290.2017.09.07.06.42.43 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 07 Sep 2017 06:42:44 -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]:40546 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dpx4s-00051q-4X for patch@linaro.org; Thu, 07 Sep 2017 09:42:42 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56496) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dpwr6-00011n-U8 for qemu-devel@nongnu.org; Thu, 07 Sep 2017 09:28:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dpwqy-0007e8-3I for qemu-devel@nongnu.org; Thu, 07 Sep 2017 09:28:28 -0400 Received: from orth.archaic.org.uk ([2001:8b0:1d0::2]:37188) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dpwqx-0007a4-RR for qemu-devel@nongnu.org; Thu, 07 Sep 2017 09:28:20 -0400 Received: from pm215 by orth.archaic.org.uk with local (Exim 4.89) (envelope-from ) id 1dpwqw-0001eB-P9 for qemu-devel@nongnu.org; Thu, 07 Sep 2017 14:28:18 +0100 From: Peter Maydell To: qemu-devel@nongnu.org Date: Thu, 7 Sep 2017 14:28:15 +0100 Message-Id: <1504790904-17018-23-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1504790904-17018-1-git-send-email-peter.maydell@linaro.org> References: <1504790904-17018-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/31] target/arm: Make MPU_CTRL register banked for v8M 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 MPU_CTRL register banked if v8M security extensions are enabled. Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson Message-id: 1503414539-28762-16-git-send-email-peter.maydell@linaro.org --- target/arm/cpu.h | 2 +- hw/intc/armv7m_nvic.c | 9 +++++---- target/arm/helper.c | 5 +++-- target/arm/machine.c | 3 ++- 4 files changed, 11 insertions(+), 8 deletions(-) -- 2.7.4 diff --git a/target/arm/cpu.h b/target/arm/cpu.h index 425adc3..29ffb26 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -429,7 +429,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 */ + unsigned mpu_ctrl[2]; /* MPU_CTRL */ int exception; uint32_t primask[2]; uint32_t faultmask[2]; diff --git a/hw/intc/armv7m_nvic.c b/hw/intc/armv7m_nvic.c index c3c214c..a4c298f 100644 --- a/hw/intc/armv7m_nvic.c +++ b/hw/intc/armv7m_nvic.c @@ -541,7 +541,7 @@ static uint32_t nvic_readl(NVICState *s, uint32_t offset, MemTxAttrs attrs) return cpu->pmsav7_dregion << 8; break; case 0xd94: /* MPU_CTRL */ - return cpu->env.v7m.mpu_ctrl; + return cpu->env.v7m.mpu_ctrl[attrs.secure]; case 0xd98: /* MPU_RNR */ return cpu->env.pmsav7.rnr[attrs.secure]; case 0xd9c: /* MPU_RBAR */ @@ -720,9 +720,10 @@ static void nvic_writel(NVICState *s, uint32_t offset, uint32_t value, qemu_log_mask(LOG_GUEST_ERROR, "MPU_CTRL: HFNMIENA and !ENABLE is " "UNPREDICTABLE\n"); } - cpu->env.v7m.mpu_ctrl = value & (R_V7M_MPU_CTRL_ENABLE_MASK | - R_V7M_MPU_CTRL_HFNMIENA_MASK | - R_V7M_MPU_CTRL_PRIVDEFENA_MASK); + cpu->env.v7m.mpu_ctrl[attrs.secure] + = value & (R_V7M_MPU_CTRL_ENABLE_MASK | + R_V7M_MPU_CTRL_HFNMIENA_MASK | + R_V7M_MPU_CTRL_PRIVDEFENA_MASK); tlb_flush(CPU(cpu)); break; case 0xd98: /* MPU_RNR */ diff --git a/target/arm/helper.c b/target/arm/helper.c index 4db191e..cc68688 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -7091,7 +7091,7 @@ static inline bool regime_translation_disabled(CPUARMState *env, ARMMMUIdx mmu_idx) { if (arm_feature(env, ARM_FEATURE_M)) { - switch (env->v7m.mpu_ctrl & + switch (env->v7m.mpu_ctrl[regime_is_secure(env, mmu_idx)] & (R_V7M_MPU_CTRL_ENABLE_MASK | R_V7M_MPU_CTRL_HFNMIENA_MASK)) { case R_V7M_MPU_CTRL_ENABLE_MASK: /* Enabled, but not for HardFault and NMI */ @@ -8251,7 +8251,8 @@ static bool pmsav7_use_background_region(ARMCPU *cpu, } if (arm_feature(env, ARM_FEATURE_M)) { - return env->v7m.mpu_ctrl & R_V7M_MPU_CTRL_PRIVDEFENA_MASK; + return env->v7m.mpu_ctrl[regime_is_secure(env, mmu_idx)] + & R_V7M_MPU_CTRL_PRIVDEFENA_MASK; } else { return regime_sctlr(env, mmu_idx) & SCTLR_BR; } diff --git a/target/arm/machine.c b/target/arm/machine.c index 7f894e5..666655d 100644 --- a/target/arm/machine.c +++ b/target/arm/machine.c @@ -123,7 +123,7 @@ static const VMStateDescription vmstate_m = { VMSTATE_UINT32(env.v7m.dfsr, ARMCPU), VMSTATE_UINT32(env.v7m.mmfar, ARMCPU), VMSTATE_UINT32(env.v7m.bfar, ARMCPU), - VMSTATE_UINT32(env.v7m.mpu_ctrl, ARMCPU), + VMSTATE_UINT32(env.v7m.mpu_ctrl[M_REG_NS], ARMCPU), VMSTATE_INT32(env.v7m.exception, ARMCPU), VMSTATE_END_OF_LIST() }, @@ -270,6 +270,7 @@ static const VMStateDescription vmstate_m_security = { 0, vmstate_info_uint32, uint32_t), VMSTATE_UINT32(env.pmsav7.rnr[M_REG_S], ARMCPU), VMSTATE_VALIDATE("secure MPU_RNR is valid", s_rnr_vmstate_validate), + VMSTATE_UINT32(env.v7m.mpu_ctrl[M_REG_S], ARMCPU), VMSTATE_END_OF_LIST() } }; From patchwork Thu Sep 7 13:28:16 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 111918 Delivered-To: patch@linaro.org Received: by 10.140.94.239 with SMTP id g102csp93930qge; Thu, 7 Sep 2017 06:29:05 -0700 (PDT) X-Google-Smtp-Source: ADKCNb5YiQKAzdu9qHVC8ORZTHNDaVscCpAuTlA8VyP6Tl1+V8fn1QkY72k2CC1/H2uSPAcQ2S/v X-Received: by 10.55.92.7 with SMTP id q7mr3420210qkb.236.1504790945824; Thu, 07 Sep 2017 06:29:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1504790945; cv=none; d=google.com; s=arc-20160816; b=JqckQRFtqkud9lvy/ISZXYUZy83AhtrILta0pFcnpvUUvMFiiD/5+GePeagwtkrAgz oyYQhKtEoQDW+HQ0yXP7cupFvzDHu3HIFmKXoZeksFHn8zgb2BHUvOyLpiid1eqVcu2R fJv/g/NMjF+02A5O5PKhbHaaxd7x4M0Jtlr+/jvebmm3d/8d6qmUpb8F2hHPhHFJGV5y 53Sjfm6CwnR0/aTNuyf+0lxaDAhaV5UMDsKCf0XOLy0z1laqII9IBpQR36WErfHBaPNZ SbVQTW07fAeNt6brtNGAGc2bx4wVibYVdPI8aYcfOM8DM30FUJx1TfMAqESHc9/xLYub zQ5A== 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=3pFNWJlTC73f7TWvYKwdt0KrMuvUah0K3NzbWYuwiFI=; b=VzDFVJdr/FMEyQdVyblp1pbMsKUOov//oejmvn7oC/HYdJvIFz5KZZMd3V3iX4HaLV 4igtbLNF9F9g+frj29/iXhlz85jPhF7VOVYZ0x2wHQONYIJCZWubEFgvIGFNbIA5D9s6 +9an5onLX+faqQMqb2/0qEOlVypofqHcyNhzmbhWm9Ly/Q508eybeD383tA/vwqc6aXF tqXhnKfo8sFHX//XsKQM1VMzQHDK7S85c2oOdQX9q0F5ag8BHmW3dDjjYyv7xNhulFa+ BNW9sNnoOto1setLkrHD9oBeOTTMWChJqk9ZrZCDXP3sVXz/7z2je7ZlZrMroz85PzN+ +57w== 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 s2si2843825qti.449.2017.09.07.06.29.05 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 07 Sep 2017 06:29: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]:40497 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dpwrf-0001FB-JY for patch@linaro.org; Thu, 07 Sep 2017 09:29:03 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56494) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dpwr6-00011k-Rf for qemu-devel@nongnu.org; Thu, 07 Sep 2017 09:28:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dpwqy-0007ej-NZ for qemu-devel@nongnu.org; Thu, 07 Sep 2017 09:28:28 -0400 Received: from orth.archaic.org.uk ([2001:8b0:1d0::2]:37196) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dpwqy-0007dn-DX for qemu-devel@nongnu.org; Thu, 07 Sep 2017 09:28:20 -0400 Received: from pm215 by orth.archaic.org.uk with local (Exim 4.89) (envelope-from ) id 1dpwqx-0001ek-E9 for qemu-devel@nongnu.org; Thu, 07 Sep 2017 14:28:19 +0100 From: Peter Maydell To: qemu-devel@nongnu.org Date: Thu, 7 Sep 2017 14:28:16 +0100 Message-Id: <1504790904-17018-24-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1504790904-17018-1-git-send-email-peter.maydell@linaro.org> References: <1504790904-17018-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 23/31] target/arm: Make CCR register banked for v8M 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 CCR register banked if v8M security extensions are enabled. This is slightly more complicated than the other "add banking" patches because there is one bit in the register which is not banked. We keep the live data in the NS copy of the register, and adjust it on register reads and writes. (Since we don't currently implement the behaviour that the bit controls, there is nowhere else that needs to care.) This patch includes the enforcement of the bits which are newly RES1 in ARMv8M. Signed-off-by: Peter Maydell Message-id: 1503414539-28762-17-git-send-email-peter.maydell@linaro.org --- target/arm/cpu.h | 2 +- hw/intc/armv7m_nvic.c | 33 +++++++++++++++++++++++++++------ target/arm/cpu.c | 12 +++++++++--- target/arm/helper.c | 5 +++-- target/arm/machine.c | 3 ++- 5 files changed, 42 insertions(+), 13 deletions(-) -- 2.7.4 diff --git a/target/arm/cpu.h b/target/arm/cpu.h index 29ffb26..d223446 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -423,7 +423,7 @@ typedef struct CPUARMState { uint32_t vecbase[2]; uint32_t basepri[2]; uint32_t control[2]; - uint32_t ccr; /* Configuration and Control */ + uint32_t ccr[2]; /* Configuration and Control */ uint32_t cfsr; /* Configurable Fault Status */ uint32_t hfsr; /* HardFault Status */ uint32_t dfsr; /* Debug Fault Status Register */ diff --git a/hw/intc/armv7m_nvic.c b/hw/intc/armv7m_nvic.c index a4c298f..a889397 100644 --- a/hw/intc/armv7m_nvic.c +++ b/hw/intc/armv7m_nvic.c @@ -448,7 +448,12 @@ static uint32_t nvic_readl(NVICState *s, uint32_t offset, MemTxAttrs attrs) /* TODO: Implement SLEEPONEXIT. */ return 0; case 0xd14: /* Configuration Control. */ - return cpu->env.v7m.ccr; + /* The BFHFNMIGN bit is the only non-banked bit; we + * keep it in the non-secure copy of the register. + */ + val = cpu->env.v7m.ccr[attrs.secure]; + val |= cpu->env.v7m.ccr[M_REG_NS] & R_V7M_CCR_BFHFNMIGN_MASK; + return val; case 0xd24: /* System Handler Status. */ val = 0; if (s->vectors[ARMV7M_EXCP_MEM].active) { @@ -673,7 +678,20 @@ static void nvic_writel(NVICState *s, uint32_t offset, uint32_t value, R_V7M_CCR_USERSETMPEND_MASK | R_V7M_CCR_NONBASETHRDENA_MASK); - cpu->env.v7m.ccr = value; + if (arm_feature(&cpu->env, ARM_FEATURE_V8)) { + /* v8M makes NONBASETHRDENA and STKALIGN be RES1 */ + value |= R_V7M_CCR_NONBASETHRDENA_MASK + | R_V7M_CCR_STKALIGN_MASK; + } + if (attrs.secure) { + /* the BFHFNMIGN bit is not banked; keep that in the NS copy */ + cpu->env.v7m.ccr[M_REG_NS] = + (cpu->env.v7m.ccr[M_REG_NS] & ~R_V7M_CCR_BFHFNMIGN_MASK) + | (value & R_V7M_CCR_BFHFNMIGN_MASK); + value &= ~R_V7M_CCR_BFHFNMIGN_MASK; + } + + cpu->env.v7m.ccr[attrs.secure] = value; break; case 0xd24: /* System Handler Control. */ s->vectors[ARMV7M_EXCP_MEM].active = (value & (1 << 0)) != 0; @@ -860,12 +878,15 @@ static void nvic_writel(NVICState *s, uint32_t offset, uint32_t value, } } -static bool nvic_user_access_ok(NVICState *s, hwaddr offset) +static bool nvic_user_access_ok(NVICState *s, hwaddr offset, MemTxAttrs attrs) { /* 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; + /* For access via STIR_NS it is the NS CCR.USERSETMPEND that + * controls access even though the CPU is in Secure state (I_QDKX). + */ + return s->cpu->env.v7m.ccr[attrs.secure] & R_V7M_CCR_USERSETMPEND_MASK; default: /* All other user accesses cause a BusFault unconditionally */ return false; @@ -881,7 +902,7 @@ static MemTxResult nvic_sysreg_read(void *opaque, hwaddr addr, unsigned i, startvec, end; uint32_t val; - if (attrs.user && !nvic_user_access_ok(s, addr)) { + if (attrs.user && !nvic_user_access_ok(s, addr, attrs)) { /* Generate BusFault for unprivileged accesses */ return MEMTX_ERROR; } @@ -971,7 +992,7 @@ static MemTxResult nvic_sysreg_write(void *opaque, hwaddr addr, trace_nvic_sysreg_write(addr, value, size); - if (attrs.user && !nvic_user_access_ok(s, addr)) { + if (attrs.user && !nvic_user_access_ok(s, addr, attrs)) { /* Generate BusFault for unprivileged accesses */ return MEMTX_ERROR; } diff --git a/target/arm/cpu.c b/target/arm/cpu.c index b7f5ec2..116b567 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -189,11 +189,17 @@ static void arm_cpu_reset(CPUState *s) env->v7m.secure = true; } - /* The reset value of this bit is IMPDEF, but ARM recommends + /* In v7M 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. + * it dependent on CPU model. In v8M it is RES1. */ - env->v7m.ccr = R_V7M_CCR_STKALIGN_MASK; + env->v7m.ccr[M_REG_NS] = R_V7M_CCR_STKALIGN_MASK; + env->v7m.ccr[M_REG_S] = R_V7M_CCR_STKALIGN_MASK; + if (arm_feature(env, ARM_FEATURE_V8)) { + /* in v8M the NONBASETHRDENA bit [0] is RES1 */ + env->v7m.ccr[M_REG_NS] |= R_V7M_CCR_NONBASETHRDENA_MASK; + env->v7m.ccr[M_REG_S] |= R_V7M_CCR_NONBASETHRDENA_MASK; + } /* Unlike A/R profile, M profile defines the reset LR value */ env->regs[14] = 0xffffffff; diff --git a/target/arm/helper.c b/target/arm/helper.c index cc68688..2fe1662 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -6113,7 +6113,8 @@ static void v7m_push_stack(ARMCPU *cpu) uint32_t xpsr = xpsr_read(env); /* Align stack pointer if the guest wants that */ - if ((env->regs[13] & 4) && (env->v7m.ccr & R_V7M_CCR_STKALIGN_MASK)) { + if ((env->regs[13] & 4) && + (env->v7m.ccr[env->v7m.secure] & R_V7M_CCR_STKALIGN_MASK)) { env->regs[13] -= 4; xpsr |= XPSR_SPREALIGN; } @@ -6211,7 +6212,7 @@ static void do_v7m_exception_exit(ARMCPU *cpu) /* fall through */ case 9: /* Return to Thread using Main stack */ if (!rettobase && - !(env->v7m.ccr & R_V7M_CCR_NONBASETHRDENA_MASK)) { + !(env->v7m.ccr[env->v7m.secure] & R_V7M_CCR_NONBASETHRDENA_MASK)) { ufault = true; } break; diff --git a/target/arm/machine.c b/target/arm/machine.c index 666655d..d740e83 100644 --- a/target/arm/machine.c +++ b/target/arm/machine.c @@ -117,7 +117,7 @@ static const VMStateDescription vmstate_m = { VMSTATE_UINT32(env.v7m.vecbase[M_REG_NS], ARMCPU), VMSTATE_UINT32(env.v7m.basepri[M_REG_NS], ARMCPU), VMSTATE_UINT32(env.v7m.control[M_REG_NS], ARMCPU), - VMSTATE_UINT32(env.v7m.ccr, ARMCPU), + VMSTATE_UINT32(env.v7m.ccr[M_REG_NS], ARMCPU), VMSTATE_UINT32(env.v7m.cfsr, ARMCPU), VMSTATE_UINT32(env.v7m.hfsr, ARMCPU), VMSTATE_UINT32(env.v7m.dfsr, ARMCPU), @@ -271,6 +271,7 @@ static const VMStateDescription vmstate_m_security = { VMSTATE_UINT32(env.pmsav7.rnr[M_REG_S], ARMCPU), VMSTATE_VALIDATE("secure MPU_RNR is valid", s_rnr_vmstate_validate), VMSTATE_UINT32(env.v7m.mpu_ctrl[M_REG_S], ARMCPU), + VMSTATE_UINT32(env.v7m.ccr[M_REG_S], ARMCPU), VMSTATE_END_OF_LIST() } }; From patchwork Thu Sep 7 13:28:17 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 111939 Delivered-To: patch@linaro.org Received: by 10.140.94.239 with SMTP id g102csp114920qge; Thu, 7 Sep 2017 06:45:16 -0700 (PDT) X-Google-Smtp-Source: AOwi7QB7KXmNkwp8TH9iPqTMtVIRSJTa4Vjy4FqzmunsGfh6bHwPvnHB9MDkTuZ3IRJC2mms9UPD X-Received: by 10.55.159.130 with SMTP id i124mr3823810qke.339.1504791916463; Thu, 07 Sep 2017 06:45:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1504791916; cv=none; d=google.com; s=arc-20160816; b=c4DMKVd7lAVyrjoh6zptLL3wXjqI/4R4Gv6WYmSgSGlUnOAO+YG+DtGUWk9TpSctqA 1tduDiKdCS03G0iG6dLcxKtJ21FIq9E+p0iNg1W8wzn6NAp+a43HVyAr0T+Gmv1MaWxB sh/3XCueiNuyPWPBtaNgXZlsJhHe2eGAQJ2pH9xaqmNI8IJuI0p8OAD0TrZ4aVPg5rPX FC5TvknEeyxYpt/ki9myRLbYZc1Lhtjai6IchEWpP/jD2OufJt+VhSXRjKVCDAtPXPy5 /mdZ3CYVKD1woMjq4gEbwPEoJGLeoKVZ+DyypfD9wRypGsJ6jOpnFWaF1rvDioEL3uPo ohLQ== 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=38zHyDm4M+Q4++nuSRMY6juzn2qXBnd+Ae3hn+CMNNw=; b=rTwOzL+Cp09gkDxHd6dLS9zdT9wt1FiXCNrOQAUj/n6S+k6h/8tYVeIrBUODQp+7iq R7DV08oTmPM05yH+VQq5Z84Awi5GJ17AANMncoxvpVVXop08uEDuQwMSGinFfdYPIthK /PHGZVH41Ly6B/O3W6V3W27sV8kIV1tgRSADV0iSeFDU2yqrxlTBCbFRPeIRBq6CLvFq aoUIvFWHoHmAGLEAXYghb9gC6K9dQ7OP7yxWVMySfRxw7m3Dcas8GJXZICIQIRbI1slC k/EDgxD7566frHlggOMXfoHp0kUThsy78SMC10Z+fPKKLy9JrFKACBP0C1br/4w2BHAo LpuA== 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 s124si935551qke.370.2017.09.07.06.45.16 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 07 Sep 2017 06:45: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]:40557 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dpx7K-0007Tq-Bz for patch@linaro.org; Thu, 07 Sep 2017 09:45:14 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56518) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dpwr7-00012T-J6 for qemu-devel@nongnu.org; Thu, 07 Sep 2017 09:28:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dpwqz-0007fe-DS for qemu-devel@nongnu.org; Thu, 07 Sep 2017 09:28:29 -0400 Received: from orth.archaic.org.uk ([2001:8b0:1d0::2]:37194) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dpwqz-0007cY-6M for qemu-devel@nongnu.org; Thu, 07 Sep 2017 09:28:21 -0400 Received: from pm215 by orth.archaic.org.uk with local (Exim 4.89) (envelope-from ) id 1dpwqy-0001fT-4C for qemu-devel@nongnu.org; Thu, 07 Sep 2017 14:28:20 +0100 From: Peter Maydell To: qemu-devel@nongnu.org Date: Thu, 7 Sep 2017 14:28:17 +0100 Message-Id: <1504790904-17018-25-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1504790904-17018-1-git-send-email-peter.maydell@linaro.org> References: <1504790904-17018-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 24/31] target/arm: Make MMFAR banked for v8M 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 MMFAR register banked if v8M security extensions are enabled. Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson Message-id: 1503414539-28762-18-git-send-email-peter.maydell@linaro.org --- target/arm/cpu.h | 2 +- hw/intc/armv7m_nvic.c | 4 ++-- target/arm/helper.c | 4 ++-- target/arm/machine.c | 3 ++- 4 files changed, 7 insertions(+), 6 deletions(-) -- 2.7.4 diff --git a/target/arm/cpu.h b/target/arm/cpu.h index d223446..03a47de 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -427,7 +427,7 @@ typedef struct CPUARMState { uint32_t cfsr; /* Configurable Fault Status */ uint32_t hfsr; /* HardFault Status */ uint32_t dfsr; /* Debug Fault Status Register */ - uint32_t mmfar; /* MemManage Fault Address */ + uint32_t mmfar[2]; /* MemManage Fault Address */ uint32_t bfar; /* BusFault Address */ unsigned mpu_ctrl[2]; /* MPU_CTRL */ int exception; diff --git a/hw/intc/armv7m_nvic.c b/hw/intc/armv7m_nvic.c index a889397..dd0710a 100644 --- a/hw/intc/armv7m_nvic.c +++ b/hw/intc/armv7m_nvic.c @@ -506,7 +506,7 @@ static uint32_t nvic_readl(NVICState *s, uint32_t offset, MemTxAttrs attrs) case 0xd30: /* Debug Fault Status. */ return cpu->env.v7m.dfsr; case 0xd34: /* MMFAR MemManage Fault Address */ - return cpu->env.v7m.mmfar; + return cpu->env.v7m.mmfar[attrs.secure]; case 0xd38: /* Bus Fault Address. */ return cpu->env.v7m.bfar; case 0xd3c: /* Aux Fault Status. */ @@ -720,7 +720,7 @@ static void nvic_writel(NVICState *s, uint32_t offset, uint32_t value, cpu->env.v7m.dfsr &= ~value; /* W1C */ break; case 0xd34: /* Mem Manage Address. */ - cpu->env.v7m.mmfar = value; + cpu->env.v7m.mmfar[attrs.secure] = value; return; case 0xd38: /* Bus Fault Address. */ cpu->env.v7m.bfar = value; diff --git a/target/arm/helper.c b/target/arm/helper.c index 2fe1662..cd95474 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -6375,10 +6375,10 @@ void arm_v7m_cpu_do_interrupt(CPUState *cs) case EXCP_DATA_ABORT: env->v7m.cfsr |= (R_V7M_CFSR_DACCVIOL_MASK | R_V7M_CFSR_MMARVALID_MASK); - env->v7m.mmfar = env->exception.vaddress; + env->v7m.mmfar[env->v7m.secure] = env->exception.vaddress; qemu_log_mask(CPU_LOG_INT, "...with CFSR.DACCVIOL and MMFAR 0x%x\n", - env->v7m.mmfar); + env->v7m.mmfar[env->v7m.secure]); break; } armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_MEM); diff --git a/target/arm/machine.c b/target/arm/machine.c index d740e83..7a96986 100644 --- a/target/arm/machine.c +++ b/target/arm/machine.c @@ -121,7 +121,7 @@ static const VMStateDescription vmstate_m = { VMSTATE_UINT32(env.v7m.cfsr, ARMCPU), VMSTATE_UINT32(env.v7m.hfsr, ARMCPU), VMSTATE_UINT32(env.v7m.dfsr, ARMCPU), - VMSTATE_UINT32(env.v7m.mmfar, ARMCPU), + VMSTATE_UINT32(env.v7m.mmfar[M_REG_NS], ARMCPU), VMSTATE_UINT32(env.v7m.bfar, ARMCPU), VMSTATE_UINT32(env.v7m.mpu_ctrl[M_REG_NS], ARMCPU), VMSTATE_INT32(env.v7m.exception, ARMCPU), @@ -272,6 +272,7 @@ static const VMStateDescription vmstate_m_security = { VMSTATE_VALIDATE("secure MPU_RNR is valid", s_rnr_vmstate_validate), VMSTATE_UINT32(env.v7m.mpu_ctrl[M_REG_S], ARMCPU), VMSTATE_UINT32(env.v7m.ccr[M_REG_S], ARMCPU), + VMSTATE_UINT32(env.v7m.mmfar[M_REG_S], ARMCPU), VMSTATE_END_OF_LIST() } }; From patchwork Thu Sep 7 13:28:18 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 111926 Delivered-To: patch@linaro.org Received: by 10.140.94.239 with SMTP id g102csp101362qge; Thu, 7 Sep 2017 06:34:41 -0700 (PDT) X-Google-Smtp-Source: ADKCNb7hhzKKqz8qtLDcrVA3UKD1Tc8tcDt3AxnoFLJLaU3qB3mcTmJlg5An+7iUKk1//srUN5NV X-Received: by 10.55.97.208 with SMTP id v199mr3492722qkb.165.1504791281451; Thu, 07 Sep 2017 06:34:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1504791281; cv=none; d=google.com; s=arc-20160816; b=Vgra0fdK1WT/AvN/MjPrkbPyo3S6ituiV1iC701O7t3rJO93UmxpNun0GG7vHWr4h4 A2EYMLKeRr8FacXqTl/P2NEWqTBqROAigwez5a+x/Hu70RIYl/sBLztpkgeSjB6Wi2VT exQcQkRqpA9J3FMPBaaymi5CDTUhKMct1FaIViT7MWiiUkwVSgIfYeUO7E7RQDpqNRrH foGKd+bqbs2SwADUqjtSZgTb+rYW2sOnOnMt5HUybz6jZVis/9nqo+14t3wyU5RzVu9S TpeXq0NSl35OtlkPw842ovy4wm+fUHDiGZB/sAlaT36EXb9oGgqziFpzNuIfEnp2plsl XvRw== 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=fAjIr1oz+b91X93mltkccWkSmQfXjs37HgNv4Mmzg8Y=; b=M6igBfulFpCWRh0KpHLHiEg4zCZOtCyLESj+gBKfzPb6wtNn9SrJfcIZ1wNL+2I2Ly dHg4Sy4g49TruXpC2SbGgtAj9SDP8C1hXW1Nmn7lqFxYx0QzTpzpISmuQ4/ksLWjVHoa UtO2yMXJKZ3SjwlmqLwfUKnB9X+VoMjw+kihECULEmMSSmgh3pwXnF1Sv3Y7y+xNtBEx 1ZVeJPOy4gt/RC9q32TUQtpdpIrEAcrbP9et8UjY7+Jvc3/+ZBr0I8bOlBUy5rIWJKi7 qE1YYlBG8knfdMqj9Ss6bNrmQBP+s5GvRwZodzRJtnyRlWR2nKIoVEZW9Dsr1PbjVXFJ juTw== 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 z4si2826965qti.22.2017.09.07.06.34.41 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 07 Sep 2017 06:34:41 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; 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]:40516 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dpwx5-00068A-8M for patch@linaro.org; Thu, 07 Sep 2017 09:34:39 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56595) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dpwrB-00016c-NS for qemu-devel@nongnu.org; Thu, 07 Sep 2017 09:28:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dpwr0-0007g2-6s for qemu-devel@nongnu.org; Thu, 07 Sep 2017 09:28:33 -0400 Received: from orth.archaic.org.uk ([2001:8b0:1d0::2]:37198) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dpwqz-0007fH-S2 for qemu-devel@nongnu.org; Thu, 07 Sep 2017 09:28:22 -0400 Received: from pm215 by orth.archaic.org.uk with local (Exim 4.89) (envelope-from ) id 1dpwqy-0001gW-SN for qemu-devel@nongnu.org; Thu, 07 Sep 2017 14:28:20 +0100 From: Peter Maydell To: qemu-devel@nongnu.org Date: Thu, 7 Sep 2017 14:28:18 +0100 Message-Id: <1504790904-17018-26-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1504790904-17018-1-git-send-email-peter.maydell@linaro.org> References: <1504790904-17018-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/31] target/arm: Make CFSR register banked for v8M 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 CFSR register banked if v8M security extensions are enabled. Not all the bits in this register are banked: the BFSR bits [15:8] are shared between S and NS, and we store them in the NS copy of the register. Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson Message-id: 1503414539-28762-19-git-send-email-peter.maydell@linaro.org --- target/arm/cpu.h | 7 ++++++- hw/intc/armv7m_nvic.c | 15 +++++++++++++-- target/arm/helper.c | 18 +++++++++--------- target/arm/machine.c | 3 ++- 4 files changed, 30 insertions(+), 13 deletions(-) -- 2.7.4 diff --git a/target/arm/cpu.h b/target/arm/cpu.h index 03a47de..41e270c 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -424,7 +424,7 @@ typedef struct CPUARMState { uint32_t basepri[2]; uint32_t control[2]; uint32_t ccr[2]; /* Configuration and Control */ - uint32_t cfsr; /* Configurable Fault Status */ + uint32_t cfsr[2]; /* Configurable Fault Status */ uint32_t hfsr; /* HardFault Status */ uint32_t dfsr; /* Debug Fault Status Register */ uint32_t mmfar[2]; /* MemManage Fault Address */ @@ -1209,6 +1209,11 @@ FIELD(V7M_CFSR, NOCP, 16 + 3, 1) FIELD(V7M_CFSR, UNALIGNED, 16 + 8, 1) FIELD(V7M_CFSR, DIVBYZERO, 16 + 9, 1) +/* V7M CFSR bit masks covering all of the subregister bits */ +FIELD(V7M_CFSR, MMFSR, 0, 8) +FIELD(V7M_CFSR, BFSR, 8, 8) +FIELD(V7M_CFSR, UFSR, 16, 16) + /* V7M HFSR bits */ FIELD(V7M_HFSR, VECTTBL, 1, 1) FIELD(V7M_HFSR, FORCED, 30, 1) diff --git a/hw/intc/armv7m_nvic.c b/hw/intc/armv7m_nvic.c index dd0710a..1fecfd6 100644 --- a/hw/intc/armv7m_nvic.c +++ b/hw/intc/armv7m_nvic.c @@ -500,7 +500,12 @@ static uint32_t nvic_readl(NVICState *s, uint32_t offset, MemTxAttrs attrs) } return val; case 0xd28: /* Configurable Fault Status. */ - return cpu->env.v7m.cfsr; + /* The BFSR bits [15:8] are shared between security states + * and we store them in the NS copy + */ + val = cpu->env.v7m.cfsr[attrs.secure]; + val |= cpu->env.v7m.cfsr[M_REG_NS] & R_V7M_CFSR_BFSR_MASK; + return val; case 0xd2c: /* Hard Fault Status. */ return cpu->env.v7m.hfsr; case 0xd30: /* Debug Fault Status. */ @@ -711,7 +716,13 @@ static void nvic_writel(NVICState *s, uint32_t offset, uint32_t value, nvic_irq_update(s); break; case 0xd28: /* Configurable Fault Status. */ - cpu->env.v7m.cfsr &= ~value; /* W1C */ + cpu->env.v7m.cfsr[attrs.secure] &= ~value; /* W1C */ + if (attrs.secure) { + /* The BFSR bits [15:8] are shared between security states + * and we store them in the NS copy. + */ + cpu->env.v7m.cfsr[M_REG_NS] &= ~(value & R_V7M_CFSR_BFSR_MASK); + } break; case 0xd2c: /* Hard Fault Status. */ cpu->env.v7m.hfsr &= ~value; /* W1C */ diff --git a/target/arm/helper.c b/target/arm/helper.c index cd95474..1c47f71 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -6224,7 +6224,7 @@ static void do_v7m_exception_exit(ARMCPU *cpu) /* Bad exception return: instead of popping the exception * stack, directly take a usage fault on the current stack. */ - env->v7m.cfsr |= R_V7M_CFSR_INVPC_MASK; + env->v7m.cfsr[env->v7m.secure] |= R_V7M_CFSR_INVPC_MASK; armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_USAGE); v7m_exception_taken(cpu, type | 0xf0000000); qemu_log_mask(CPU_LOG_INT, "...taking UsageFault on existing " @@ -6266,7 +6266,7 @@ static void do_v7m_exception_exit(ARMCPU *cpu) 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; + env->v7m.cfsr[env->v7m.secure] |= R_V7M_CFSR_INVPC_MASK; v7m_push_stack(cpu); v7m_exception_taken(cpu, type | 0xf0000000); qemu_log_mask(CPU_LOG_INT, "...taking UsageFault on new stackframe: " @@ -6325,15 +6325,15 @@ void arm_v7m_cpu_do_interrupt(CPUState *cs) switch (cs->exception_index) { case EXCP_UDEF: armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_USAGE); - env->v7m.cfsr |= R_V7M_CFSR_UNDEFINSTR_MASK; + env->v7m.cfsr[env->v7m.secure] |= R_V7M_CFSR_UNDEFINSTR_MASK; break; case EXCP_NOCP: armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_USAGE); - env->v7m.cfsr |= R_V7M_CFSR_NOCP_MASK; + env->v7m.cfsr[env->v7m.secure] |= R_V7M_CFSR_NOCP_MASK; break; case EXCP_INVSTATE: armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_USAGE); - env->v7m.cfsr |= R_V7M_CFSR_INVSTATE_MASK; + env->v7m.cfsr[env->v7m.secure] |= R_V7M_CFSR_INVSTATE_MASK; break; case EXCP_SWI: /* The PC already points to the next instruction. */ @@ -6349,11 +6349,11 @@ void arm_v7m_cpu_do_interrupt(CPUState *cs) case 0x8: /* External Abort */ switch (cs->exception_index) { case EXCP_PREFETCH_ABORT: - env->v7m.cfsr |= R_V7M_CFSR_PRECISERR_MASK; + env->v7m.cfsr[M_REG_NS] |= R_V7M_CFSR_PRECISERR_MASK; qemu_log_mask(CPU_LOG_INT, "...with CFSR.PRECISERR\n"); break; case EXCP_DATA_ABORT: - env->v7m.cfsr |= + env->v7m.cfsr[M_REG_NS] |= (R_V7M_CFSR_IBUSERR_MASK | R_V7M_CFSR_BFARVALID_MASK); env->v7m.bfar = env->exception.vaddress; qemu_log_mask(CPU_LOG_INT, @@ -6369,11 +6369,11 @@ void arm_v7m_cpu_do_interrupt(CPUState *cs) */ switch (cs->exception_index) { case EXCP_PREFETCH_ABORT: - env->v7m.cfsr |= R_V7M_CFSR_IACCVIOL_MASK; + env->v7m.cfsr[env->v7m.secure] |= R_V7M_CFSR_IACCVIOL_MASK; qemu_log_mask(CPU_LOG_INT, "...with CFSR.IACCVIOL\n"); break; case EXCP_DATA_ABORT: - env->v7m.cfsr |= + env->v7m.cfsr[env->v7m.secure] |= (R_V7M_CFSR_DACCVIOL_MASK | R_V7M_CFSR_MMARVALID_MASK); env->v7m.mmfar[env->v7m.secure] = env->exception.vaddress; qemu_log_mask(CPU_LOG_INT, diff --git a/target/arm/machine.c b/target/arm/machine.c index 7a96986..0bcaa68 100644 --- a/target/arm/machine.c +++ b/target/arm/machine.c @@ -118,7 +118,7 @@ static const VMStateDescription vmstate_m = { VMSTATE_UINT32(env.v7m.basepri[M_REG_NS], ARMCPU), VMSTATE_UINT32(env.v7m.control[M_REG_NS], ARMCPU), VMSTATE_UINT32(env.v7m.ccr[M_REG_NS], ARMCPU), - VMSTATE_UINT32(env.v7m.cfsr, ARMCPU), + VMSTATE_UINT32(env.v7m.cfsr[M_REG_NS], ARMCPU), VMSTATE_UINT32(env.v7m.hfsr, ARMCPU), VMSTATE_UINT32(env.v7m.dfsr, ARMCPU), VMSTATE_UINT32(env.v7m.mmfar[M_REG_NS], ARMCPU), @@ -273,6 +273,7 @@ static const VMStateDescription vmstate_m_security = { VMSTATE_UINT32(env.v7m.mpu_ctrl[M_REG_S], ARMCPU), VMSTATE_UINT32(env.v7m.ccr[M_REG_S], ARMCPU), VMSTATE_UINT32(env.v7m.mmfar[M_REG_S], ARMCPU), + VMSTATE_UINT32(env.v7m.cfsr[M_REG_S], ARMCPU), VMSTATE_END_OF_LIST() } }; From patchwork Thu Sep 7 13:28:19 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 111940 Delivered-To: patch@linaro.org Received: by 10.140.94.239 with SMTP id g102csp116781qge; Thu, 7 Sep 2017 06:46:51 -0700 (PDT) X-Google-Smtp-Source: ADKCNb6eoigh5HFPzyEteMJDWiB5FKa/JHhl52KtSpNv5vwQ95gciDkr0VkOloPHHjYAq069sds2 X-Received: by 10.200.22.93 with SMTP id x29mr3729827qtk.111.1504792011027; Thu, 07 Sep 2017 06:46:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1504792011; cv=none; d=google.com; s=arc-20160816; b=uUmT5YyPyMGboCBCBaAcJm56p1HrthjRSIVcHVsI+pYG5QqQ6inIGi+MGOcUy90WKf 1QEFzezbPSxMwfixpmwcPG73pDX43BhQ2wTBOIceTRE4d5cI+vWF3LRu9XK6NzlBaZDX F/NHm0T51JEInzRIhWQK16gvsKnp3Q5oNs6mYRvqtuh6rTUDlKEK5sFUoCRUE5hcMtsU CGlztJAI6dcTWIHt9q5Q+7d1vll6MYjAzh39QqDnfDucGxHZPS1Lkts3Q7gQ+Qtm3AEp dpEFXZGhu5S6te6ropVfCMtiguvHWO6S6SSA5CrLcOz1K2c7kLwmuzDKLpKlmCpzo0GQ B4kQ== 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=hVBpHK86Hl+rxQLaZIUEmKHBiD6CUd5L8c1VHOcpkoU=; b=P3+gEXInirVR60eq3OhU3jG0KTcQ9rRxBFqiqw8HQPGmy3j4L5qxFQJMevUM7495UX Qq9n1uIImtIRYJCRpGyceMrQu/+ZXU2r19tGu7mD4XV1mzWSbj63wK3uUVUtH9RGAs8y p6KvEeHLYZPOuGYreGDGIu7tmz79IoU1Hr/76J9iqyc4HVORAmbVxMDvS9foCkEOj2ih YmVdPUoDIIR150B8DeBWbl8xCUOU4mJNF4iXwPwnoyeSKQoeWZwO6i8H7IZcpq+H6VJ5 YrKuNYw0Q31jSQ3Ok/ZOsyHF69AnUflwFF4HUaO+cFuf9oTZ3HGGLYDWiGvWBmFQ8Jad ivCg== 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 i132si2757984qke.166.2017.09.07.06.46.50 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 07 Sep 2017 06:46: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]:40565 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dpx8r-0000Cg-09 for patch@linaro.org; Thu, 07 Sep 2017 09:46:49 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56547) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dpwr8-00013B-Bz for qemu-devel@nongnu.org; Thu, 07 Sep 2017 09:28:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dpwr1-0007gM-4M for qemu-devel@nongnu.org; Thu, 07 Sep 2017 09:28:30 -0400 Received: from orth.archaic.org.uk ([2001:8b0:1d0::2]:37198) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dpwr0-0007fH-TH for qemu-devel@nongnu.org; Thu, 07 Sep 2017 09:28:23 -0400 Received: from pm215 by orth.archaic.org.uk with local (Exim 4.89) (envelope-from ) id 1dpwqz-0001gk-Id for qemu-devel@nongnu.org; Thu, 07 Sep 2017 14:28:21 +0100 From: Peter Maydell To: qemu-devel@nongnu.org Date: Thu, 7 Sep 2017 14:28:19 +0100 Message-Id: <1504790904-17018-27-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1504790904-17018-1-git-send-email-peter.maydell@linaro.org> References: <1504790904-17018-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/31] target/arm: Move regime_is_secure() to target/arm/internals.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 regime_is_secure() utility function to internals.h; we are going to want to call it from translate.c. Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson Message-id: 1503414539-28762-20-git-send-email-peter.maydell@linaro.org --- target/arm/internals.h | 26 ++++++++++++++++++++++++++ target/arm/helper.c | 26 -------------------------- 2 files changed, 26 insertions(+), 26 deletions(-) -- 2.7.4 diff --git a/target/arm/internals.h b/target/arm/internals.h index 461f558..4afebd9 100644 --- a/target/arm/internals.h +++ b/target/arm/internals.h @@ -480,4 +480,30 @@ static inline void arm_call_el_change_hook(ARMCPU *cpu) } } +/* Return true if this address translation regime is secure */ +static inline bool regime_is_secure(CPUARMState *env, ARMMMUIdx mmu_idx) +{ + switch (mmu_idx) { + case ARMMMUIdx_S12NSE0: + case ARMMMUIdx_S12NSE1: + case ARMMMUIdx_S1NSE0: + case ARMMMUIdx_S1NSE1: + case ARMMMUIdx_S1E2: + case ARMMMUIdx_S2NS: + case ARMMMUIdx_MPriv: + case ARMMMUIdx_MNegPri: + case ARMMMUIdx_MUser: + return false; + case ARMMMUIdx_S1E3: + case ARMMMUIdx_S1SE0: + case ARMMMUIdx_S1SE1: + case ARMMMUIdx_MSPriv: + case ARMMMUIdx_MSNegPri: + case ARMMMUIdx_MSUser: + return true; + default: + g_assert_not_reached(); + } +} + #endif diff --git a/target/arm/helper.c b/target/arm/helper.c index 1c47f71..00807b4 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -7055,32 +7055,6 @@ static inline uint32_t regime_el(CPUARMState *env, ARMMMUIdx mmu_idx) } } -/* Return true if this address translation regime is secure */ -static inline bool regime_is_secure(CPUARMState *env, ARMMMUIdx mmu_idx) -{ - switch (mmu_idx) { - case ARMMMUIdx_S12NSE0: - case ARMMMUIdx_S12NSE1: - case ARMMMUIdx_S1NSE0: - case ARMMMUIdx_S1NSE1: - case ARMMMUIdx_S1E2: - case ARMMMUIdx_S2NS: - case ARMMMUIdx_MPriv: - case ARMMMUIdx_MNegPri: - case ARMMMUIdx_MUser: - return false; - case ARMMMUIdx_S1E3: - case ARMMMUIdx_S1SE0: - case ARMMMUIdx_S1SE1: - case ARMMMUIdx_MSPriv: - case ARMMMUIdx_MSNegPri: - case ARMMMUIdx_MSUser: - return true; - default: - g_assert_not_reached(); - } -} - /* Return the SCTLR value which controls this address translation regime */ static inline uint32_t regime_sctlr(CPUARMState *env, ARMMMUIdx mmu_idx) { From patchwork Thu Sep 7 13:28:20 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 111929 Delivered-To: patch@linaro.org Received: by 10.140.94.239 with SMTP id g102csp105709qge; Thu, 7 Sep 2017 06:37:51 -0700 (PDT) X-Google-Smtp-Source: ADKCNb7CyJuz9NFtR6wQkULyw9R4a/JV4Mn18DmnYbWoa5x+G9rTEJWaoOEVps3XvPn15t9BPE/A X-Received: by 10.200.4.146 with SMTP id s18mr3687783qtg.240.1504791460797; Thu, 07 Sep 2017 06:37:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1504791459; cv=none; d=google.com; s=arc-20160816; b=Kbnp+I0xH0UQm5prSA0Qt2g89cQmoZyb879aOpcGIpkAdT1ER2tSU9GZyVGX748pQH 1IV5ZslX2uBrmfo35GkBcqylD46E/hDKyPFtwV7Rfrq7e4H8m3S1FQtEtg5cQADAR5pc w63yJSBD5PinMupT1Ko/JqfAgiVaBTKT2jZQ4OnQOOrnChzGGDsApNFB8fkg4JdUN+jx QdUuF1eY/pBM2scuHiWd+sbeQ5XxdlT29NacGlBi3PHvVsKGk/2CtG5Zpv5g4kCV/pH2 gY7yGRgv7D67dNzAQPWKU8/MO18DjNpQDU97qH+NfB5dGC88a2I1hRBzyyzbdhznuKqC Igng== 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=kAAsqmkzpcniMj7zfuexG2QEbz/PdqcQoZ3xPsNk5ls=; b=BD1bUVksDvUii+2QEikL2XnhLsQGRYPD5pgcAx9WyUeXgAdNa60U0XCFm+fgytBQud SZnYcqJxOFbSC3LxEYEotXjxoAZt8PADy7SP11Np2ThtGn2aPtFBod0QQySGxn4t8Rfg oCEsrgz+Jh6lWYydEemrgFDPGgq/5NYYAI/T/wQo53zHNjX+i8mGKALh/5xE2guCX0K7 6l7tc+sUFSj6k4ab+yuBI5TnGS1RQUYIFx8mutb7NCKKjGaexQtXP03j+IqJngFjMjqY NvNHArmfHUfP1eCeyMtw9bFBExUWvrUmmpja+VmhYVMWjsEfpwfxZ+fmRKAFkl0sqxyZ 4k7Q== 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 c42si1300860qtd.226.2017.09.07.06.37.39 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 07 Sep 2017 06:37: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]:40529 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dpwzx-0000Xq-CQ for patch@linaro.org; Thu, 07 Sep 2017 09:37:37 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56584) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dpwrA-00014k-5m for qemu-devel@nongnu.org; Thu, 07 Sep 2017 09:28:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dpwr1-0007gi-Kl for qemu-devel@nongnu.org; Thu, 07 Sep 2017 09:28:32 -0400 Received: from orth.archaic.org.uk ([2001:8b0:1d0::2]:37200) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dpwr1-0007gC-8n for qemu-devel@nongnu.org; Thu, 07 Sep 2017 09:28:23 -0400 Received: from pm215 by orth.archaic.org.uk with local (Exim 4.89) (envelope-from ) id 1dpwr0-0001hM-9U for qemu-devel@nongnu.org; Thu, 07 Sep 2017 14:28:22 +0100 From: Peter Maydell To: qemu-devel@nongnu.org Date: Thu, 7 Sep 2017 14:28:20 +0100 Message-Id: <1504790904-17018-28-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1504790904-17018-1-git-send-email-peter.maydell@linaro.org> References: <1504790904-17018-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/31] target/arm: Implement BXNS, and banked stack pointers 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 BXNS v8M instruction, which is like BX but will do a jump-and-switch-to-NonSecure if the branch target address has bit 0 clear. This is the first piece of code which implements "switch to the other security state", so the commit also includes the code to switch the stack pointers around, which is the only complicated part of switching security state. BLXNS is more complicated than just "BXNS but set the link register", so we leave it for a separate commit. Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson Message-id: 1503414539-28762-21-git-send-email-peter.maydell@linaro.org --- target/arm/cpu.h | 13 +++++++++ target/arm/helper.h | 2 ++ target/arm/translate.h | 1 + target/arm/helper.c | 79 ++++++++++++++++++++++++++++++++++++++++++++++++++ target/arm/machine.c | 2 ++ target/arm/translate.c | 42 ++++++++++++++++++++++++++- 6 files changed, 138 insertions(+), 1 deletion(-) -- 2.7.4 diff --git a/target/arm/cpu.h b/target/arm/cpu.h index 41e270c..0f40a64 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -419,7 +419,20 @@ typedef struct CPUARMState { } cp15; struct { + /* M profile has up to 4 stack pointers: + * a Main Stack Pointer and a Process Stack Pointer for each + * of the Secure and Non-Secure states. (If the CPU doesn't support + * the security extension then it has only two SPs.) + * In QEMU we always store the currently active SP in regs[13], + * and the non-active SP for the current security state in + * v7m.other_sp. The stack pointers for the inactive security state + * are stored in other_ss_msp and other_ss_psp. + * switch_v7m_security_state() is responsible for rearranging them + * when we change security state. + */ uint32_t other_sp; + uint32_t other_ss_msp; + uint32_t other_ss_psp; uint32_t vecbase[2]; uint32_t basepri[2]; uint32_t control[2]; diff --git a/target/arm/helper.h b/target/arm/helper.h index df86bf7..64afbac 100644 --- a/target/arm/helper.h +++ b/target/arm/helper.h @@ -63,6 +63,8 @@ DEF_HELPER_1(cpsr_read, i32, env) DEF_HELPER_3(v7m_msr, void, env, i32, i32) DEF_HELPER_2(v7m_mrs, i32, env, i32) +DEF_HELPER_2(v7m_bxns, void, env, i32) + DEF_HELPER_4(access_check_cp_reg, void, env, ptr, i32, i32) DEF_HELPER_3(set_cp_reg, void, env, ptr, i32) DEF_HELPER_2(get_cp_reg, i32, env, ptr) diff --git a/target/arm/translate.h b/target/arm/translate.h index 2fe144b..ef625ad 100644 --- a/target/arm/translate.h +++ b/target/arm/translate.h @@ -32,6 +32,7 @@ typedef struct DisasContext { int vec_len; int vec_stride; bool v7m_handler_mode; + bool v8m_secure; /* true if v8M and we're in Secure mode */ /* Immediate value in AArch32 SVC insn; must be set if is_jmp == DISAS_SWI * so that top level loop can generate correct syndrome information. */ diff --git a/target/arm/helper.c b/target/arm/helper.c index 00807b4..329e517 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -5870,6 +5870,12 @@ uint32_t HELPER(v7m_mrs)(CPUARMState *env, uint32_t reg) return 0; } +void HELPER(v7m_bxns)(CPUARMState *env, uint32_t dest) +{ + /* translate.c should never generate calls here in user-only mode */ + g_assert_not_reached(); +} + void switch_mode(CPUARMState *env, int mode) { ARMCPU *cpu = arm_env_get_cpu(env); @@ -6044,6 +6050,18 @@ static uint32_t v7m_pop(CPUARMState *env) return val; } +/* Return true if we're using the process stack pointer (not the MSP) */ +static bool v7m_using_psp(CPUARMState *env) +{ + /* Handler mode always uses the main stack; for thread mode + * the CONTROL.SPSEL bit determines the answer. + * Note that in v7M it is not possible to be in Handler mode with + * CONTROL.SPSEL non-zero, but in v8M it is, so we must check both. + */ + return !arm_v7m_is_handler_mode(env) && + env->v7m.control[env->v7m.secure] & R_V7M_CONTROL_SPSEL_MASK; +} + /* Switch to V7M main or process stack pointer. */ static void switch_v7m_sp(CPUARMState *env, bool new_spsel) { @@ -6062,6 +6080,67 @@ static void switch_v7m_sp(CPUARMState *env, bool new_spsel) } } +/* Switch M profile security state between NS and S */ +static void switch_v7m_security_state(CPUARMState *env, bool new_secstate) +{ + uint32_t new_ss_msp, new_ss_psp; + + if (env->v7m.secure == new_secstate) { + return; + } + + /* All the banked state is accessed by looking at env->v7m.secure + * except for the stack pointer; rearrange the SP appropriately. + */ + new_ss_msp = env->v7m.other_ss_msp; + new_ss_psp = env->v7m.other_ss_psp; + + if (v7m_using_psp(env)) { + env->v7m.other_ss_psp = env->regs[13]; + env->v7m.other_ss_msp = env->v7m.other_sp; + } else { + env->v7m.other_ss_msp = env->regs[13]; + env->v7m.other_ss_psp = env->v7m.other_sp; + } + + env->v7m.secure = new_secstate; + + if (v7m_using_psp(env)) { + env->regs[13] = new_ss_psp; + env->v7m.other_sp = new_ss_msp; + } else { + env->regs[13] = new_ss_msp; + env->v7m.other_sp = new_ss_psp; + } +} + +void HELPER(v7m_bxns)(CPUARMState *env, uint32_t dest) +{ + /* Handle v7M BXNS: + * - if the return value is a magic value, do exception return (like BX) + * - otherwise bit 0 of the return value is the target security state + */ + if (dest >= 0xff000000) { + /* This is an exception return magic value; put it where + * do_v7m_exception_exit() expects and raise EXCEPTION_EXIT. + * Note that if we ever add gen_ss_advance() singlestep support to + * M profile this should count as an "instruction execution complete" + * event (compare gen_bx_excret_final_code()). + */ + env->regs[15] = dest & ~1; + env->thumb = dest & 1; + HELPER(exception_internal)(env, EXCP_EXCEPTION_EXIT); + /* notreached */ + } + + /* translate.c should have made BXNS UNDEF unless we're secure */ + assert(env->v7m.secure); + + switch_v7m_security_state(env, dest & 1); + env->thumb = 1; + env->regs[15] = dest & ~1; +} + static uint32_t arm_v7m_load_vector(ARMCPU *cpu) { CPUState *cs = CPU(cpu); diff --git a/target/arm/machine.c b/target/arm/machine.c index 0bcaa68..e5fe083 100644 --- a/target/arm/machine.c +++ b/target/arm/machine.c @@ -257,6 +257,8 @@ static const VMStateDescription vmstate_m_security = { .needed = m_security_needed, .fields = (VMStateField[]) { VMSTATE_UINT32(env.v7m.secure, ARMCPU), + VMSTATE_UINT32(env.v7m.other_ss_msp, ARMCPU), + VMSTATE_UINT32(env.v7m.other_ss_psp, ARMCPU), VMSTATE_UINT32(env.v7m.basepri[M_REG_S], ARMCPU), VMSTATE_UINT32(env.v7m.primask[M_REG_S], ARMCPU), VMSTATE_UINT32(env.v7m.faultmask[M_REG_S], ARMCPU), diff --git a/target/arm/translate.c b/target/arm/translate.c index 6aa2d7c..e7966e2 100644 --- a/target/arm/translate.c +++ b/target/arm/translate.c @@ -994,6 +994,25 @@ static inline void gen_bx_excret_final_code(DisasContext *s) gen_exception_internal(EXCP_EXCEPTION_EXIT); } +static inline void gen_bxns(DisasContext *s, int rm) +{ + TCGv_i32 var = load_reg(s, rm); + + /* The bxns helper may raise an EXCEPTION_EXIT exception, so in theory + * we need to sync state before calling it, but: + * - we don't need to do gen_set_pc_im() because the bxns helper will + * always set the PC itself + * - we don't need to do gen_set_condexec() because BXNS is UNPREDICTABLE + * unless it's outside an IT block or the last insn in an IT block, + * so we know that condexec == 0 (already set at the top of the TB) + * is correct in the non-UNPREDICTABLE cases, and we can choose + * "zeroes the IT bits" as our UNPREDICTABLE behaviour otherwise. + */ + gen_helper_v7m_bxns(cpu_env, var); + tcg_temp_free_i32(var); + s->is_jmp = DISAS_EXIT; +} + /* Variant of store_reg which uses branch&exchange logic when storing to r15 in ARM architecture v7 and above. The source must be a temporary and will be marked as dead. */ @@ -11185,12 +11204,31 @@ static void disas_thumb_insn(CPUARMState *env, DisasContext *s) */ bool link = insn & (1 << 7); - if (insn & 7) { + if (insn & 3) { goto undef; } if (link) { ARCH(5); } + if ((insn & 4)) { + /* BXNS/BLXNS: only exists for v8M with the + * security extensions, and always UNDEF if NonSecure. + * We don't implement these in the user-only mode + * either (in theory you can use them from Secure User + * mode but they are too tied in to system emulation.) + */ + if (!s->v8m_secure || IS_USER_ONLY) { + goto undef; + } + if (link) { + /* BLXNS: not yet implemented */ + goto undef; + } else { + gen_bxns(s, rm); + } + break; + } + /* BLX/BX */ tmp = load_reg(s, rm); if (link) { val = (uint32_t)s->pc | 1; @@ -11878,6 +11916,8 @@ void gen_intermediate_code(CPUState *cs, TranslationBlock *tb) dc->vec_stride = ARM_TBFLAG_VECSTRIDE(tb->flags); dc->c15_cpar = ARM_TBFLAG_XSCALE_CPAR(tb->flags); dc->v7m_handler_mode = ARM_TBFLAG_HANDLER(tb->flags); + dc->v8m_secure = arm_feature(env, ARM_FEATURE_M_SECURITY) && + regime_is_secure(env, dc->mmu_idx); dc->cp_regs = cpu->cp_regs; dc->features = env->features; From patchwork Thu Sep 7 13:28:21 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 111943 Delivered-To: patch@linaro.org Received: by 10.140.94.239 with SMTP id g102csp119278qge; Thu, 7 Sep 2017 06:49:06 -0700 (PDT) X-Google-Smtp-Source: ADKCNb6OkGb2r4ovvL5nXGbjKdInNab/kqFQMm7KTfgCxg0wEuSDq71UMiRljtih/8LOMGf4A+Bc X-Received: by 10.200.15.132 with SMTP id b4mr4085362qtk.127.1504792146425; Thu, 07 Sep 2017 06:49:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1504792146; cv=none; d=google.com; s=arc-20160816; b=PIeRyAOEBGRSct1KM47BXU/Vj3GB8PohVZx+gbB1oPnbD1ku5i9dsN5IXFE4/UK98P go5o7h4gAR/O3FgDMiVPeSkAVTbpAZkbkURueiJvdvabO0VfM6gSWX6jNmpc6s7BcJmh Rzdm2VJHBFR9t3r8+eYyQE8ZIO+t5REoPzH/S97kPWWpyT6/dgRJyytWV8OshdikqUd9 cRCH0QbsMTgtp13YeFqb9neDYME4VVm00BvcJ+k3/Qj8/ugzCRazBBwN8duVACMQiLPT 7MT4JJu2Ife+3hsx76DAb73X4Mb3BFbZoEGsQt8kD1TbMW5OISfYKlPEFxp581PWf+KS 3YvQ== 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=lOUkMSL/TOLCcveUgKl4x0oFgiJhqvjftk95gTYoIDk=; b=MWoQ1bNsJHuwg3OEsNRP/RXbhr8APSr0E7wO17efcBytI4pwz0QnTSu6rAr4VbAwvH 9Az/nmIP9DtCtltSgzYm60vGgtHxAt+6FteA5cO5d0uB3++k/kGl+dOF1aELmNvBF/NF 6wuoIeCzC7VnQfeGgrNpzKBkUq9p4987gMYb/RGGFQYfv8Xpffaj+9EEWmr3cLhv6sr0 Jtn5+y99qYQEIZ23gkQkHqyQTrJfHrychDF2dtXE3Blh36h1AH4j+SMSHcEdwT5Xm6+M WRScMne0qjB+lh3pd/YN0/SQAYT9kUNOgadrLqJ5PrpsAi8Yz1MuWyryOySGltLb6YAf hWaA== 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 e81si2913924qkj.483.2017.09.07.06.49.06 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 07 Sep 2017 06:49:06 -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]:40571 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dpxB2-0002Pd-Be for patch@linaro.org; Thu, 07 Sep 2017 09:49:04 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56612) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dpwrC-00017d-JS for qemu-devel@nongnu.org; Thu, 07 Sep 2017 09:28:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dpwr2-0007hU-Hi for qemu-devel@nongnu.org; Thu, 07 Sep 2017 09:28:34 -0400 Received: from orth.archaic.org.uk ([2001:8b0:1d0::2]:37200) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dpwr2-0007gC-AD for qemu-devel@nongnu.org; Thu, 07 Sep 2017 09:28:24 -0400 Received: from pm215 by orth.archaic.org.uk with local (Exim 4.89) (envelope-from ) id 1dpwr0-0001hd-V6 for qemu-devel@nongnu.org; Thu, 07 Sep 2017 14:28:22 +0100 From: Peter Maydell To: qemu-devel@nongnu.org Date: Thu, 7 Sep 2017 14:28:21 +0100 Message-Id: <1504790904-17018-29-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1504790904-17018-1-git-send-email-peter.maydell@linaro.org> References: <1504790904-17018-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/31] 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 Reviewed-by: Richard Henderson Reviewed-by: Alistair Francis Message-id: 1504626814-23124-2-git-send-email-peter.maydell@linaro.org --- include/hw/boards.h | 11 +++++++++++ include/qom/cpu.h | 7 ++++++- qom/cpu.c | 16 ++++++++++++++++ 3 files changed, 33 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..dc5392d 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,21 @@ 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(); + + /* qdev_get_machine() can return something that's not TYPE_MACHINE + * if this is one of the user-only emulators; in that case there's + * no need to check the ignore_memory_transaction_failures board flag. + */ + if (object_dynamic_cast(machine, TYPE_MACHINE)) { + ObjectClass *oc = object_get_class(machine); + MachineClass *mc = MACHINE_CLASS(oc); + + if (mc) { + cpu->ignore_memory_transaction_failures = + mc->ignore_memory_transaction_failures; + } + } if (dev->hotplugged) { cpu_synchronize_post_init(cpu); From patchwork Thu Sep 7 13:28:22 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 111949 Delivered-To: patch@linaro.org Received: by 10.140.94.239 with SMTP id g102csp123599qge; Thu, 7 Sep 2017 06:53:07 -0700 (PDT) X-Google-Smtp-Source: AOwi7QAs04z8LGZlVAyrtHyHiUox+2VjhpZ1nvGQD/WIcaJ00TiOJs2vJbHwmL88NOLFbs6Kcfct X-Received: by 10.55.15.65 with SMTP id z62mr3957524qkg.2.1504792387297; Thu, 07 Sep 2017 06:53:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1504792387; cv=none; d=google.com; s=arc-20160816; b=xNmOiUSMCL4bVx4LCw3dtum2ZTucK0UJRuK0QwgdwNUWT6gQkaIewCVvlMjo0MXCK0 TRCigowrT9Y8dTBKqP2itr7Iyhu9uiNsDUl27oU3feezGu9vso4meXSkWClBmj0w9tAs P58Gaq41BXdv825QcXRcieKmT2APFsXax9BeFeZ3XeaRSUG+SUHHIkTIwjkrvQ/MfnPf sMoX+GyYpNfowZsw5GHwjW3ZAbDP1SbFe6mlbpwbgo/1RWY3m5NCOhcS3a/NYJUkiDts HjvFBEy3E9kD4zJ2/uvv2Ud50yE17t6yab7ROlxEBlsOetSNY/vZpTZbMIe2zttqK7D9 tPEQ== 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=oQ41be8FRiEFeckZh/JdljfhLD+UAZ9m0VHLVUnyr74=; b=Q8Scza952WVIzMX5ByxocQB/v+xxktBc/U3ZmxDwGV5gMTd+a5fvQp5HYJtpTqG6wr mPVgpAUTBw3GmbE0szi9keYuXxlMmCNdfpFu9bV8IBVFUcbrJ64AJVzkx1hqNIT2Tuat ni3SWytzaRYCSIw3bPiXbCJDhzrfjjVKdZby3xajE9uzlB8akMeNA/d7vLwrAHYvYXHu iY1MQGAFRvXv1brMjM6S1jWzjptdH1v5OmFR+ixaeDSm8g7jSVicnZRnjZvf9hAY8uDV CCl8aK+kcvCmJxkM50Pw20ENoFbAJT2W73J8oweTUloHcr0wQcQuJlVzyd2oZpZxRwBn B9qA== 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 m35si2864976qtd.220.2017.09.07.06.53.06 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 07 Sep 2017 06:53:07 -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]:40588 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dpxEu-00060J-T0 for patch@linaro.org; Thu, 07 Sep 2017 09:53:04 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56653) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dpwrE-00019J-23 for qemu-devel@nongnu.org; Thu, 07 Sep 2017 09:28:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dpwr3-0007iD-47 for qemu-devel@nongnu.org; Thu, 07 Sep 2017 09:28:36 -0400 Received: from orth.archaic.org.uk ([2001:8b0:1d0::2]:37202) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dpwr2-0007gu-JI for qemu-devel@nongnu.org; Thu, 07 Sep 2017 09:28:25 -0400 Received: from pm215 by orth.archaic.org.uk with local (Exim 4.89) (envelope-from ) id 1dpwr1-0001iJ-Kd for qemu-devel@nongnu.org; Thu, 07 Sep 2017 14:28:23 +0100 From: Peter Maydell To: qemu-devel@nongnu.org Date: Thu, 7 Sep 2017 14:28:22 +0100 Message-Id: <1504790904-17018-30-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1504790904-17018-1-git-send-email-peter.maydell@linaro.org> References: <1504790904-17018-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/31] 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 Reviewed-by: Alistair Francis Message-id: 1504626814-23124-3-git-send-email-peter.maydell@linaro.org 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 Thu Sep 7 13:28:23 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 111947 Delivered-To: patch@linaro.org Received: by 10.140.94.239 with SMTP id g102csp121621qge; Thu, 7 Sep 2017 06:51:17 -0700 (PDT) X-Google-Smtp-Source: AOwi7QCNbcQNYv6oyD5aVwbxI+1iHkw1ihezxVnWHeG9j5dqtUMlZqZ6zRCKoe6flo2KExLEUuSq X-Received: by 10.55.76.134 with SMTP id z128mr3859316qka.183.1504792277706; Thu, 07 Sep 2017 06:51:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1504792277; cv=none; d=google.com; s=arc-20160816; b=by6MLM1SZQMP/z4HmUff0XGq3fkLogVCYtlHW8adf7UDjqZbusDBO0wHTMgOxvMBSE AzGhAOlLsF4KzkFVEoZY++GPoykaDVogoBRX2sDhlL81VX6me2ItFC5/i5ur3DMS0ALm OfgQd9umHaS2kX37as35sNpS4WjvfaIvuONDca4tXNNHIyMSvEclWD4cZN56R1nijTSl qNZNZIIhHaXYScWhLbWxNyCAFRLA67xZ5DoPc3oxoc2mS1x/zvxv3Z/vcDCPyVaergeq W+0lBTmQcz/FVzb/PHXioMvwvoN7e14XsfY0hxkqJ6HCVnXr+k9Y8Vh9l4dfwCLMOeg3 95Fw== 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=UiSotj0sezDiJQv2VP2QjD8j5ClzZxtaOFOLu2N5Ujk=; b=szvV7jb2avzXLSsBa9TzQyAO/L6+7hr7gtJZAiufhWdFVjiGCOGaL+OceOy/v1oRCx Ea/AA0ui/MnbTywROViEWetHRfpxATkgQWp6tXBrlDy7oACLwo/QkYiT+iVGWbt8OyBn Mc2Jdt4ZNn4vXPVCcrR27sW9jM0g2oZL4REQT/xDsODdLuloQ8zVWsVD2OL0AFdl3ZmP yuzTTTGIV8mWBOZg5alDq23DGALBfsCOheCdMB4U5jTdBsmcO73PCcQxD6n5BCnCJkym lFmb71WXjISUXrn4gWmU85GD2iZtoNO8vm6FZe3VHZvNJ7DebxtfcJEV4qEC1FcdKn0G Otzw== 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 f129si2907996qke.18.2017.09.07.06.51.17 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 07 Sep 2017 06:51:17 -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]:40580 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dpxD9-0004Iz-LD for patch@linaro.org; Thu, 07 Sep 2017 09:51:15 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56712) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dpwrI-0001Ei-0o for qemu-devel@nongnu.org; Thu, 07 Sep 2017 09:28:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dpwr3-0007ie-Ir for qemu-devel@nongnu.org; Thu, 07 Sep 2017 09:28:40 -0400 Received: from orth.archaic.org.uk ([2001:8b0:1d0::2]:37200) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dpwr3-0007gC-BL for qemu-devel@nongnu.org; Thu, 07 Sep 2017 09:28:25 -0400 Received: from pm215 by orth.archaic.org.uk with local (Exim 4.89) (envelope-from ) id 1dpwr2-0001ia-99 for qemu-devel@nongnu.org; Thu, 07 Sep 2017 14:28:24 +0100 From: Peter Maydell To: qemu-devel@nongnu.org Date: Thu, 7 Sep 2017 14:28:23 +0100 Message-Id: <1504790904-17018-31-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1504790904-17018-1-git-send-email-peter.maydell@linaro.org> References: <1504790904-17018-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/31] 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 Message-id: 1504626814-23124-4-git-send-email-peter.maydell@linaro.org --- 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 4afebd9..5d7f24c 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 116b567..f8b2fdb 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -1707,6 +1707,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 Thu Sep 7 13:28:24 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 111946 Delivered-To: patch@linaro.org Received: by 10.140.94.239 with SMTP id g102csp121144qge; Thu, 7 Sep 2017 06:50:49 -0700 (PDT) X-Google-Smtp-Source: ADKCNb4ei8eGwZy6hfOtYqLz0bRW3rt+ubIJ01Lk/DFqpagimUCv4ShvQOLyMs89/Tzj5z//BKzr X-Received: by 10.237.33.102 with SMTP id 93mr4096120qtc.267.1504792249897; Thu, 07 Sep 2017 06:50:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1504792249; cv=none; d=google.com; s=arc-20160816; b=DEoLsc7sVlZeAI/LDsdHLLJNrKp2ZhtWvuiVr9E8oZO0e/SPqYZfxUGAdfV+wYJYuD hgny+SVDrMhkG0rgyh0PMOzSJLIxPAZJ2Rfy4iy1O/svKlNk/9Pi7EqH3jdZhQbnVcU3 4DBIO9qz13WynS85NMZ6tc21AGXPovexCu+ogXQvm6P1tDWtNSbwENW304AGmYk/GrZf gj1An1c/gstcWcd4LAq1l2duBpXtpeDaTJlSX1Ws3Y7JRtwdtxlt6iNxaLOPiSMMvkBK 9j0/sgdE8BzRJrhjtIHB+DEKBurHAxG3ilcFtTlF4a4C41V4+/Mmi8qXM9f40r4i6nLD cktg== 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=nYRuM5ihVGgNNVQRdxp/+wKs8Ycw4T1KrbwvsXw1f4c=; b=lCF7ipXRpFx42uRmiCLx08yotxot8XPQknc1ItC3NYoTfLSQ/J/ZwzhRHHdkjTMFZp 1435/ilaigp6KAVNetmN8k8c5QIO8AfoP7CQ7GAqsCyodlEFs0rUDOeXp4O9qnj/77p8 cY0oa0ZcNEUrguv3L83MxYukttAfnpNG+YTJs18zktT86BHaFcXv937bnXNm3jf91IZp WJUfPyuHhgtDLboJ9k9nl7Rdhv0HCTMAL+uQSXv/95u4ifL3PboJ2sGa1cx/fZacq5fH a7Rd65y/vP7sv9NcJKPBnC0V/4s8+zdvDqVR7WlEr1qb1Ru59vfu1S7OR0kHP6flVHCy 3J7Q== 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 c9si3281411qkh.398.2017.09.07.06.50.49 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 07 Sep 2017 06:50:49 -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]:40577 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dpxCh-00048T-QZ for patch@linaro.org; Thu, 07 Sep 2017 09:50:47 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56739) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dpwrJ-0001G3-7s for qemu-devel@nongnu.org; Thu, 07 Sep 2017 09:28:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dpwr4-0007j3-C3 for qemu-devel@nongnu.org; Thu, 07 Sep 2017 09:28:41 -0400 Received: from orth.archaic.org.uk ([2001:8b0:1d0::2]:37204) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dpwr4-0007iZ-57 for qemu-devel@nongnu.org; Thu, 07 Sep 2017 09:28:26 -0400 Received: from pm215 by orth.archaic.org.uk with local (Exim 4.89) (envelope-from ) id 1dpwr3-0001j3-4c for qemu-devel@nongnu.org; Thu, 07 Sep 2017 14:28:25 +0100 From: Peter Maydell To: qemu-devel@nongnu.org Date: Thu, 7 Sep 2017 14:28:24 +0100 Message-Id: <1504790904-17018-32-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1504790904-17018-1-git-send-email-peter.maydell@linaro.org> References: <1504790904-17018-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/31] target/arm: Add Jazelle feature 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: Portia Stephens This adds a feature bit indicating support of the (trivial) Jazelle implementation if ARM_FEATURE_V6 is set or if the processor is arm926 or arm1026. This fixes the issue that any BXJ instruction will result in an illegal_op. BXJ instructions will now check if the architecture supports ARM_FEATURE_JAZELLE. Signed-off-by: Portia Stephens Reviewed-by: Alistair Francis Message-id: 20170905211232.11092-1-portia.stephens@xilinx.com [PMM: edited commit message and comment text a bit] Reviewed-by: Peter Maydell Signed-off-by: Peter Maydell --- target/arm/cpu.h | 1 + target/arm/cpu.c | 3 +++ target/arm/translate.c | 2 +- 3 files changed, 5 insertions(+), 1 deletion(-) -- 2.7.4 diff --git a/target/arm/cpu.h b/target/arm/cpu.h index 0f40a64..98b9b26 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -1296,6 +1296,7 @@ enum arm_features { ARM_FEATURE_PMU, /* has PMU support */ ARM_FEATURE_VBAR, /* has cp15 VBAR */ ARM_FEATURE_M_SECURITY, /* M profile Security Extension */ + ARM_FEATURE_JAZELLE, /* has (trivial) Jazelle implementation */ }; static inline int arm_feature(CPUARMState *env, int feature) diff --git a/target/arm/cpu.c b/target/arm/cpu.c index f8b2fdb..a1acce3 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -712,6 +712,7 @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp) } if (arm_feature(env, ARM_FEATURE_V6)) { set_feature(env, ARM_FEATURE_V5); + set_feature(env, ARM_FEATURE_JAZELLE); if (!arm_feature(env, ARM_FEATURE_M)) { set_feature(env, ARM_FEATURE_AUXCR); } @@ -927,6 +928,7 @@ static void arm926_initfn(Object *obj) set_feature(&cpu->env, ARM_FEATURE_VFP); set_feature(&cpu->env, ARM_FEATURE_DUMMY_C15_REGS); set_feature(&cpu->env, ARM_FEATURE_CACHE_TEST_CLEAN); + set_feature(&cpu->env, ARM_FEATURE_JAZELLE); cpu->midr = 0x41069265; cpu->reset_fpsid = 0x41011090; cpu->ctr = 0x1dd20d2; @@ -956,6 +958,7 @@ static void arm1026_initfn(Object *obj) set_feature(&cpu->env, ARM_FEATURE_AUXCR); set_feature(&cpu->env, ARM_FEATURE_DUMMY_C15_REGS); set_feature(&cpu->env, ARM_FEATURE_CACHE_TEST_CLEAN); + set_feature(&cpu->env, ARM_FEATURE_JAZELLE); cpu->midr = 0x4106a262; cpu->reset_fpsid = 0x410110a0; cpu->ctr = 0x1dd20d2; diff --git a/target/arm/translate.c b/target/arm/translate.c index e7966e2..57899fa 100644 --- a/target/arm/translate.c +++ b/target/arm/translate.c @@ -41,7 +41,7 @@ #define ENABLE_ARCH_5 arm_dc_feature(s, ARM_FEATURE_V5) /* currently all emulated v5 cores are also v5TE, so don't bother */ #define ENABLE_ARCH_5TE arm_dc_feature(s, ARM_FEATURE_V5) -#define ENABLE_ARCH_5J 0 +#define ENABLE_ARCH_5J arm_dc_feature(s, ARM_FEATURE_JAZELLE) #define ENABLE_ARCH_6 arm_dc_feature(s, ARM_FEATURE_V6) #define ENABLE_ARCH_6K arm_dc_feature(s, ARM_FEATURE_V6K) #define ENABLE_ARCH_6T2 arm_dc_feature(s, ARM_FEATURE_THUMB2)