From patchwork Thu Feb 21 18:57:39 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 1046404 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="u8LSmU2B"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 44540F2jw5z9s7h for ; Fri, 22 Feb 2019 06:14:21 +1100 (AEDT) Received: from localhost ([127.0.0.1]:37082 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwtnX-0005Ry-5B for incoming@patchwork.ozlabs.org; Thu, 21 Feb 2019 14:14:19 -0500 Received: from eggs.gnu.org ([209.51.188.92]:52319) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwtXv-000071-7r for qemu-devel@nongnu.org; Thu, 21 Feb 2019 13:58:12 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gwtXu-0007XS-1W for qemu-devel@nongnu.org; Thu, 21 Feb 2019 13:58:11 -0500 Received: from mail-wm1-x344.google.com ([2a00:1450:4864:20::344]:33589) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gwtXt-0007Wv-PD for qemu-devel@nongnu.org; Thu, 21 Feb 2019 13:58:09 -0500 Received: by mail-wm1-x344.google.com with SMTP id h22so7303743wmb.0 for ; Thu, 21 Feb 2019 10:58:09 -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=b/CDe6+LrSLQgWuXOF/Ks8F6XdEn0wLjjvmfORAKBsk=; b=u8LSmU2Bm3+pFcbOrf76NlSn05BrBtaBfJSctGlgzjlA2zm/PteEUgk5WdPHifavKM uvnuUyD7/vzvgUFRzw3N3Xmz/i6NOUyS8/HkZdnMVckTfOFkkb1Nd0Dr2zn666fI/4F5 rHoNGR0jmjOOtijcvUDfX/wWGknD5QilPq9il0WPai/xMpk+B7iTSxOdtHGZcdZdMzah /JGTP84YqycyXpLSA5fV4n8ttnagMLRnOT1N2n/cp6BG5rxSx3E12DU/VbPKaExA6pDF 0RxD95hduWQ33yAJDLsqkMZJx8prD86qENw0d/gbTr0elyXwgatdofQ0PaFIBMdsIWBb yhZw== 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=b/CDe6+LrSLQgWuXOF/Ks8F6XdEn0wLjjvmfORAKBsk=; b=ROErr/2HnDlY+ixkEZbPP24Ksm+pnew3XFTbaB2bZkcl5GQAymx4CRoGc6BOe3BLNg 1cH6y5GLJZ/jQJWLNZBUfYWIe43WIsw4untHz8XBSCJlfH2hIaIXFpxyK0RotNkxdAJF 4ERQvSXlJduklFPte2D59aWE4BCuxdypzQoedsDsR3wdrz4889FE2Pv2lQVACagrjrVe CEteaYd+0hOVxQc7QG5fejM4Ozm9g48HOZJlZg+MhPUM8MU38WBZHmoP+qiaYGEFEu3x 1WeHwwBTsbWbJhPY/FJqQX+Ldc5EB42LbFeFhvZI66T3jKN6kebjR39hJrFH1mH+sVh+ ycOg== X-Gm-Message-State: AHQUAuaSuoohKd8n5yoRoIXyWk3vlWKCVccBsG7mnDYjJzcoVTe4zOia TpxgE/Qv4CwJN9TYwgNab9BBlXRKI5s= X-Google-Smtp-Source: AHgI3Ibh3oJpbjQS5FT1E1WrMnb9BVN6IdB+sNTeQv3YU/Nmw0CloBx8GNPtvEtnIEbmrDxsYKoQ8g== X-Received: by 2002:a1c:228b:: with SMTP id i133mr12016052wmi.105.1550775488393; Thu, 21 Feb 2019 10:58:08 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id c18sm29065085wre.32.2019.02.21.10.58.07 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 21 Feb 2019 10:58:07 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Date: Thu, 21 Feb 2019 18:57:39 +0000 Message-Id: <20190221185739.25362-22-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190221185739.25362-1-peter.maydell@linaro.org> References: <20190221185739.25362-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::344 Subject: [Qemu-devel] [PULL 21/21] hw/arm/armsse: Make 0x5... alias region work for per-CPU devices 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" The region 0x40010000 .. 0x4001ffff and its secure-only alias at 0x50010000... are for per-CPU devices. We implement this by giving each CPU its own container memory region, where the per-CPU devices live. Unfortunately, the alias region which makes devices mapped at 0x4... addresses also appear at 0x5... is only implemented in the overall "all CPUs" container. The effect of this bug is that the CPU_IDENTITY register block appears only at 0x4001f000, but not at the 0x5001f000 alias where it should also appear. Guests (like very recent Arm Trusted Firmware-M) which try to access it at 0x5001f000 will crash. Fix this by moving the handling for this alias from the "all CPUs" container to the per-CPU container. (We leave the aliases for 0x1... and 0x3... in the overall container, because there are no per-CPU devices there.) Signed-off-by: Peter Maydell Message-id: 20190215180500.6906-1-peter.maydell@linaro.org Reviewed-by: Alex Bennée --- include/hw/arm/armsse.h | 2 +- hw/arm/armsse.c | 26 ++++++++++++++++---------- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/include/hw/arm/armsse.h b/include/hw/arm/armsse.h index 84879f40dd8..7ef871c7dfe 100644 --- a/include/hw/arm/armsse.h +++ b/include/hw/arm/armsse.h @@ -186,7 +186,7 @@ typedef struct ARMSSE { MemoryRegion cpu_container[SSE_MAX_CPUS]; MemoryRegion alias1; MemoryRegion alias2; - MemoryRegion alias3; + MemoryRegion alias3[SSE_MAX_CPUS]; MemoryRegion sram[MAX_SRAM_BANKS]; qemu_irq *exp_irqs[SSE_MAX_CPUS]; diff --git a/hw/arm/armsse.c b/hw/arm/armsse.c index 50da41f64c5..129e7ea7fe0 100644 --- a/hw/arm/armsse.c +++ b/hw/arm/armsse.c @@ -110,15 +110,16 @@ static bool irq_is_common[32] = { /* 30, 31: reserved */ }; -/* Create an alias region of @size bytes starting at @base +/* + * Create an alias region in @container of @size bytes starting at @base * which mirrors the memory starting at @orig. */ -static void make_alias(ARMSSE *s, MemoryRegion *mr, const char *name, - hwaddr base, hwaddr size, hwaddr orig) +static void make_alias(ARMSSE *s, MemoryRegion *mr, MemoryRegion *container, + const char *name, hwaddr base, hwaddr size, hwaddr orig) { - memory_region_init_alias(mr, NULL, name, &s->container, orig, size); + memory_region_init_alias(mr, NULL, name, container, orig, size); /* The alias is even lower priority than unimplemented_device regions */ - memory_region_add_subregion_overlap(&s->container, base, mr, -1500); + memory_region_add_subregion_overlap(container, base, mr, -1500); } static void irq_status_forwarder(void *opaque, int n, int level) @@ -607,16 +608,21 @@ static void armsse_realize(DeviceState *dev, Error **errp) } /* Set up the big aliases first */ - make_alias(s, &s->alias1, "alias 1", 0x10000000, 0x10000000, 0x00000000); - make_alias(s, &s->alias2, "alias 2", 0x30000000, 0x10000000, 0x20000000); + make_alias(s, &s->alias1, &s->container, "alias 1", + 0x10000000, 0x10000000, 0x00000000); + make_alias(s, &s->alias2, &s->container, + "alias 2", 0x30000000, 0x10000000, 0x20000000); /* The 0x50000000..0x5fffffff region is not a pure alias: it has * a few extra devices that only appear there (generally the * control interfaces for the protection controllers). * We implement this by mapping those devices over the top of this - * alias MR at a higher priority. + * alias MR at a higher priority. Some of the devices in this range + * are per-CPU, so we must put this alias in the per-cpu containers. */ - make_alias(s, &s->alias3, "alias 3", 0x50000000, 0x10000000, 0x40000000); - + for (i = 0; i < info->num_cpus; i++) { + make_alias(s, &s->alias3[i], &s->cpu_container[i], + "alias 3", 0x50000000, 0x10000000, 0x40000000); + } /* Security controller */ object_property_set_bool(OBJECT(&s->secctl), true, "realized", &err);