From patchwork Fri Feb 1 16:06:19 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 157268 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp633740jaa; Fri, 1 Feb 2019 08:19:50 -0800 (PST) X-Google-Smtp-Source: ALg8bN4VQOdiXEQ9TKdOBep+5b2mk00LRHfC5aQ5r54VleNthd8sLC0pUUtL+cFeIJOpxitmAJoS X-Received: by 2002:a81:34c3:: with SMTP id b186mr27725612ywa.509.1549037990155; Fri, 01 Feb 2019 08:19:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549037990; cv=none; d=google.com; s=arc-20160816; b=f13c04sxpKGnnb24ntzJLAeDfmmyMVVFeikM7Jwzkq84edCMRdHpd7SIMvqPssE/jI Kmy7azzo3W3yfaBc4Y0QOYiIjCCLvN8IUYIejV1Qx6gulPWdqnNIYnOub3LGHBuJ2MMM bKe7r7puXdFIJ8EGJ3a/lpxDVZLfRvDGIyBBFlbEVQ6YYbfZ8TbIt3FHUkPSWvIICg3m KIexSbM+XWBmIF5BCUCEbr9fMAVa9s/S0nFALZ8oV3hZ+suOBQUl6LZqC66PaddZo8O2 VcUu70sAyJD3ub9mGcDUAYCmSEfZVeVFG9y9eX0uo6arPzmvZ1IDui8dRuN7Ac330ciC PoeA== 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:dkim-signature; bh=Tlw++BIfQDFapWWcSIN4AHf97yoiN9OX+oOFYF6Vcpw=; b=eMMzmVTCNtC1jRKr+H5J4e0Iu5ZAQOS4+uk3MVUSSPqyYcBkF4pnVwfi2JR5+IQfn7 VsXxrJsDppt8ZaW9ChORZh8wyOJmQfCx9WF3bJkub6tULKRyA/xGUUpVkFFfpqM0rLzQ 1GsLMs6sGuc7Dt2GOEKvkX4JI5ObjsLi95BJCslIlg3pPhefnJ+PsCcvhsQV4JWEJJOc HmduAgI0s9UDCcYS9nSKRHuA3NyYjwTtB36Vlzfhmi+GfKo7CyTKJR1lFA9iPM6mgroN C1GOjc5m8zPeJEw71eXsz/91L9qG1O0VG+O9VSgU+1gGKgfogr2ejwh8gVTKp6zs1mza 6bvA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=UBSAfUbA; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 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. [209.51.188.17]) by mx.google.com with ESMTPS id s18si4940882ybe.134.2019.02.01.08.19.50 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 01 Feb 2019 08:19:50 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=UBSAfUbA; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 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 ([127.0.0.1]:57405 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gpbXh-0001fJ-J1 for patch@linaro.org; Fri, 01 Feb 2019 11:19:49 -0500 Received: from eggs.gnu.org ([209.51.188.92]:58962) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gpbMC-0008Fe-Qu for qemu-devel@nongnu.org; Fri, 01 Feb 2019 11:08:02 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gpbM9-0003hN-SI for qemu-devel@nongnu.org; Fri, 01 Feb 2019 11:07:56 -0500 Received: from mail-wm1-x331.google.com ([2a00:1450:4864:20::331]:35409) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gpbM9-0003Ku-Hd for qemu-devel@nongnu.org; Fri, 01 Feb 2019 11:07:53 -0500 Received: by mail-wm1-x331.google.com with SMTP id t200so6821043wmt.0 for ; Fri, 01 Feb 2019 08:07:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=Tlw++BIfQDFapWWcSIN4AHf97yoiN9OX+oOFYF6Vcpw=; b=UBSAfUbAGg/As2xyKNiytHRaE4HSJKXIpAYF/Wuk44ngzAv/po9epBwWtBcPlH8svT mXl9FUnLnyHv0yUw6Gs6Z3r0dXDV4teVT6b4jsXNdX1rWzeHaY3pjzf5Rcr78uG280zX T/3k/R9rMELR+DPfDuwWlRwuOKfA2qiX3NMqo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Tlw++BIfQDFapWWcSIN4AHf97yoiN9OX+oOFYF6Vcpw=; b=UuIDdZZ/T4zPhYpB+5gH7rJ/bzvkkzIZXe1731+OAq8Q/2n4gsd2qfhN7kWY2kewdM BN0HxzjwdHD9gQZXsMohzgr7eCH7s7f/R+r8cDNvNaa+Y8e19v56FbBVLqFWBVSfdSYY sv365s75TPoko/6wlcybAG6OcHv1nBjEfFPtbM1p9Q/xGLauRBWBELpvr8Q4ve7pv6h7 1RDQOzbECj8puOaOE2UCQbtnxcdZ2PGzaXQYfngQsuwOq6k4VnTozMju57dPuEpvk9ak zrFYnEczKwSlXMgUaxJo08jwSD8bCbzTX16Ric/p56nEhIoqTA4e/Iaq71APK6q0ekbD n44w== X-Gm-Message-State: AHQUAua9R0sD9xtT/+aB8JHvDVz1yxGSsmVBoqQFnu9uUvS+Q5SzqqeM gde1WXj399GlVvJxZWy6rnMsjvH+RKvF/Q== X-Received: by 2002:a1c:6243:: with SMTP id w64mr2967373wmb.153.1549037233609; Fri, 01 Feb 2019 08:07:13 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id n6sm2847250wmk.9.2019.02.01.08.07.12 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 01 Feb 2019 08:07:12 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Date: Fri, 1 Feb 2019 16:06:19 +0000 Message-Id: <20190201160653.13829-14-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190201160653.13829-1-peter.maydell@linaro.org> References: <20190201160653.13829-1-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: 2a00:1450:4864:20::331 Subject: [Qemu-devel] [PULL 13/47] hw/arm/armsse: Give each CPU its own view of memory 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" Give each CPU its own container memory region. This is necessary for two reasons: * some devices are instantiated one per CPU and the CPU sees only its own device * since a memory region can only be put into one container, we must give each armv7m object a different MemoryRegion as its 'memory' property, or a dual-CPU configuration will assert on realize when the second armv7m object tries to put the MR into a container when it is already in the first armv7m object's container Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson Message-id: 20190121185118.18550-13-peter.maydell@linaro.org --- include/hw/arm/armsse.h | 10 ++++++++++ hw/arm/armsse.c | 22 ++++++++++++++++++++-- 2 files changed, 30 insertions(+), 2 deletions(-) -- 2.20.1 diff --git a/include/hw/arm/armsse.h b/include/hw/arm/armsse.h index faf5dfed252..89f19a971f4 100644 --- a/include/hw/arm/armsse.h +++ b/include/hw/arm/armsse.h @@ -135,7 +135,17 @@ typedef struct ARMSSE { IoTKitSysCtl sysctl; IoTKitSysCtl sysinfo; + /* + * 'container' holds all devices seen by all CPUs. + * 'cpu_container[i]' is the view that CPU i has: this has the + * per-CPU devices of that CPU, plus as the background 'container' + * (or an alias of it, since we can only use it directly once). + * container_alias[i] is the alias of 'container' used by CPU i+1; + * CPU 0 can use 'container' directly. + */ MemoryRegion container; + MemoryRegion container_alias[SSE_MAX_CPUS - 1]; + MemoryRegion cpu_container[SSE_MAX_CPUS]; MemoryRegion alias1; MemoryRegion alias2; MemoryRegion alias3; diff --git a/hw/arm/armsse.c b/hw/arm/armsse.c index 5cb2b78b1fc..2472dfef3a1 100644 --- a/hw/arm/armsse.c +++ b/hw/arm/armsse.c @@ -153,6 +153,15 @@ static void armsse_init(Object *obj) qdev_prop_set_string(DEVICE(&s->armv7m[i]), "cpu-type", ARM_CPU_TYPE_NAME("cortex-m33")); g_free(name); + name = g_strdup_printf("arm-sse-cpu-container%d", i); + memory_region_init(&s->cpu_container[i], obj, name, UINT64_MAX); + g_free(name); + if (i > 0) { + name = g_strdup_printf("arm-sse-container-alias%d", i); + memory_region_init_alias(&s->container_alias[i - 1], obj, + name, &s->container, 0, UINT64_MAX); + g_free(name); + } } sysbus_init_child_obj(obj, "secctl", &s->secctl, sizeof(s->secctl), @@ -332,7 +341,7 @@ static void armsse_realize(DeviceState *dev, Error **errp) * 0x50000000..0x5fffffff alias of 0x40000000..0x4fffffff */ - memory_region_add_subregion_overlap(&s->container, 0, s->board_memory, -1); + memory_region_add_subregion_overlap(&s->container, 0, s->board_memory, -2); for (i = 0; i < info->num_cpus; i++) { DeviceState *cpudev = DEVICE(&s->armv7m[i]); @@ -373,7 +382,16 @@ static void armsse_realize(DeviceState *dev, Error **errp) return; } } - object_property_set_link(cpuobj, OBJECT(&s->container), "memory", &err); + + if (i > 0) { + memory_region_add_subregion_overlap(&s->cpu_container[i], 0, + &s->container_alias[i - 1], -1); + } else { + memory_region_add_subregion_overlap(&s->cpu_container[i], 0, + &s->container, -1); + } + object_property_set_link(cpuobj, OBJECT(&s->cpu_container[i]), + "memory", &err); if (err) { error_propagate(errp, err); return;