From patchwork Thu Feb 21 18:57:19 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 158941 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp844078jaa; Thu, 21 Feb 2019 11:09:26 -0800 (PST) X-Google-Smtp-Source: AHgI3IYkDzv9/xCFdABDVSPnrWniU8awN/rcQwiPK/n64VN2vzEHxxcIhJZPelKOjj/hATwIuL0a X-Received: by 2002:a81:3b96:: with SMTP id i144mr38976ywa.155.1550776166912; Thu, 21 Feb 2019 11:09:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550776166; cv=none; d=google.com; s=arc-20160816; b=CSOH/O8K7mKs+PTSv4lC2miTZTISmsO74ls9skrVFeTFg77WeFuAfMeEKP6IYJlf5Y P8BkMJvMUxlcIWsR2UhYlK9cp26sWgSKHgIUP+7nqtw44sqkkLpXa804UtBadDB8Akjc WF/+kDth6KSmOGjk9UoMmryPRcyLLbKfn/OwH5AyXNTkOEnxBR79NmAJPLyExGpVuuXk A0cjObG+xy0diy3WXZUyh3UXpYjGxUdt+QFsB3Qwhu2lte91r5HrY+taVOV47Zn5oLBF CShEBeBTqtZ8XhATJGl0SLFXGwXUxnRfUOdud/E9V3igtJsMBjtpoq8/P2EAMnBBhvA0 hCvQ== 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=de17OJhtWJ4ic9K1WXyC5Ixt9mKMZ8x4NgCd17XgBZA=; b=Cu3eYFVMZjpd+BLgBhbU31AjinfljC3k/5Laaq93KyhD5i1a9OA0tXqD6rNeswH4JJ IxOGCcqMeXIeHiwM8NE2auKReXIg1wKK2Z/6kMITBzrRcSq+3BdjRaB4EEl0++E9kyBU qUqkpCfUayKA1BVbgEKyqqqERuNcV2rFkm62fwaCixONwzJ44/VIuIKA4t0hPIrGXK3o 7vUBXbl+CyQR71glAR+svLjKgIhGj17NQLR/gN2kLv0JLV/gx93LAHFGCQ5csXGuGd/3 4s9JIiKmJoF8qyknTQui7v64CjwUe71hGkYpRVUklo/ZTGBLqhMCjw/ctRQx5SFhEQex wFJg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=vkpErFFg; 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 b144si8358990yba.72.2019.02.21.11.09.26 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 21 Feb 2019 11:09:26 -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=vkpErFFg; 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]:37010 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwtio-0000yQ-95 for patch@linaro.org; Thu, 21 Feb 2019 14:09:26 -0500 Received: from eggs.gnu.org ([209.51.188.92]:52026) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwtXj-0008N8-3k for qemu-devel@nongnu.org; Thu, 21 Feb 2019 13:58:00 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gwtXg-0007My-Eg for qemu-devel@nongnu.org; Thu, 21 Feb 2019 13:57:58 -0500 Received: from mail-wr1-x433.google.com ([2a00:1450:4864:20::433]:35733) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gwtXV-0007GN-Lz for qemu-devel@nongnu.org; Thu, 21 Feb 2019 13:57:49 -0500 Received: by mail-wr1-x433.google.com with SMTP id t18so31878773wrx.2 for ; Thu, 21 Feb 2019 10:57:44 -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=de17OJhtWJ4ic9K1WXyC5Ixt9mKMZ8x4NgCd17XgBZA=; b=vkpErFFgavI+B0PRl2M1TqEk/OytTvoM6f9uRERVeOvBWzu0v1DMu20QykGHWhmYmc Qdh1EBMR905qqxNK497tiEj9GfkjazDbnj6yNAXqVRgw6V6M7zjKpq5o1ayxkPmCO1IZ lr96jIwIxTgi270RefFw8VuHocsS0JQU4egPFQUYE8yxwDICtOePV27UeixHKBSKltNu 4hZ1f03av5tCWNtYeO4dF06DhUFlOoreugRn/TQbqECIXoPQeB25GTYednszNdLl1DRS HcHk7OhK/GAMa9PIteAZDOVzJbk1FtHNhjVcEpP6C2Y8SSLlRbxzLcA/lcZdfJJrG5iS lDsg== 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=de17OJhtWJ4ic9K1WXyC5Ixt9mKMZ8x4NgCd17XgBZA=; b=FHQPxfgnQZ7OyyoCqySKEDP2vgcS9S8tZXak+JFWgDNy28FwM1vn2nmSOa7HOm0LYZ IdRZ2OVHPSPoSng7sAktgvgMIuMQKZL3aiRXElrCEQ2pYw+tEetrPFRvxXL3PSu498Ls Y5U0LgluOljGqu33UT4CA08J47hrpF6dFLjQVlSo7vhzbONuOwP0jWJ26LfkP90i1Rpc n7zVpm00LzpIiqQOvh2ww88pL9ZxkmfFizjL0PsQ6h5ZTjAYoFL1ZO6maiMm+eshvAmq 7mPdb4WdvKLe3aqLrxylMt/bp7QxTN/I3lNw1BjlZqeyeiQPX3ulnpDfFDXy1V5IqEov 7duA== X-Gm-Message-State: AHQUAuYuD2Ym2XL5/y4Mtx7AWhLDRy8hswBqxEIjTOT384a9eVmnYvUO o27h68U+Go7o1VsJOQ8koXKw4b4Ufek= X-Received: by 2002:adf:a4c9:: with SMTP id h9mr8244wrb.254.1550775463046; Thu, 21 Feb 2019 10:57:43 -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.57.42 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 21 Feb 2019 10:57:42 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Date: Thu, 21 Feb 2019 18:57:19 +0000 Message-Id: <20190221185739.25362-2-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::433 Subject: [Qemu-devel] [PULL 01/21] hw/arm/armsse: Fix memory leak in error-exit path 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" Coverity points out (CID 1398632, CID 1398650) that we leak a couple of allocated strings in the error-exit code path for setting up the MHUs in the ARMSSE. Fix this bug by moving the allocate-and-free of each string to be closer to the use, so we do the free before doing the error-exit check. Fixes: f8574705f62b38a ("hw/arm/armsse: Add unimplemented-device stubs for MHUs") Signed-off-by: Peter Maydell Reviewed-by: Philippe Mathieu-Daudé Message-id: 20190215113707.24553-1-peter.maydell@linaro.org --- hw/arm/armsse.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) -- 2.20.1 diff --git a/hw/arm/armsse.c b/hw/arm/armsse.c index 9a8c49547db..d0207dbabc7 100644 --- a/hw/arm/armsse.c +++ b/hw/arm/armsse.c @@ -762,26 +762,28 @@ static void armsse_realize(DeviceState *dev, Error **errp) if (info->has_mhus) { for (i = 0; i < ARRAY_SIZE(s->mhu); i++) { - char *name = g_strdup_printf("MHU%d", i); - char *port = g_strdup_printf("port[%d]", i + 3); + char *name; + char *port; + name = g_strdup_printf("MHU%d", i); qdev_prop_set_string(DEVICE(&s->mhu[i]), "name", name); qdev_prop_set_uint64(DEVICE(&s->mhu[i]), "size", 0x1000); object_property_set_bool(OBJECT(&s->mhu[i]), true, "realized", &err); + g_free(name); if (err) { error_propagate(errp, err); return; } + port = g_strdup_printf("port[%d]", i + 3); mr = sysbus_mmio_get_region(SYS_BUS_DEVICE(&s->mhu[i]), 0); object_property_set_link(OBJECT(&s->apb_ppc0), OBJECT(mr), port, &err); + g_free(port); if (err) { error_propagate(errp, err); return; } - g_free(name); - g_free(port); } } From patchwork Thu Feb 21 18:57:20 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 158930 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp832524jaa; Thu, 21 Feb 2019 10:58:42 -0800 (PST) X-Google-Smtp-Source: AHgI3IaPJQVBR8rRCu5aPIIq2ifx76zUr3HyJyLkpm1VyV0wQJAdRkkV4lozQPkwg+e8yOVly4MA X-Received: by 2002:a25:4189:: with SMTP id o131mr19625yba.348.1550775522021; Thu, 21 Feb 2019 10:58:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550775522; cv=none; d=google.com; s=arc-20160816; b=N+iiIUfvmzmoRXemXRDsZsH1Sa/yqMnFajssNWcyJP18vHNAaqPANgpMugohPgTobx 1pk/pK3XjwiyBp1PNn/7qeJFAnLQ8U+Eo43nzC15BBHx21Wm8hy6z1no9S/LF98fL/+e pH0xsFXRU9oJSHAD2kZtTx3Ozs6EX0PI7KJppJEZIuI3v44apYrLN0f2Wd8KbZJxShC6 5N2JGfe46fZ6Y9urgMbJL6wa6bagZqRNYvDqQA7LE0FHjxqgH5NHR0H1YMHzBj76phDb bASD7HQLFb2lv8uTtrUSYXMHGQ6C0H3Z+X+gYEDB4484TYh2/pRE+8p3jPkcefibfeg1 c3rw== 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=xUAIzDpNWv8YnIShod0ImX2EP9PZydu99S3FvI92H14=; b=I+Z8P/Dbo5sHo8+O3FGOVRYXKyL0E5Fc9C1FRi4ULHs2IckA34k99jwcCwxjuDR349 W2u67p7LAK8yChvy/ickrX/0o05OlUJaIwhW3NrCZOt+iFQqbk9xUVKFgsqjzl/GEglj 2CYPuF4BcUVl/qTO5Hu9FmrZyNu46r/n1TuQRbLc7CLwIf46XsqL6qUO8aepZkmQ4V7m o/pBmSel9F6Epl/1Yr/LAGpEMF7B1pREBotEj6s8BSEfwM79GkrBYTXwP8/OpLmynxPe pMlqVs1J5KmAVeHN2hkfPPhqkKsSbn2mBDwNvR+8mDb6n/GVNQ5gSMkET2LHFsKHyXXu X4YQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=OZl0YjBv; 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 f38si13587432ybi.388.2019.02.21.10.58.41 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 21 Feb 2019 10:58:42 -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=OZl0YjBv; 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]:36867 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwtYP-0000Fd-FO for patch@linaro.org; Thu, 21 Feb 2019 13:58:41 -0500 Received: from eggs.gnu.org ([209.51.188.92]:52027) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwtXj-0008NC-44 for qemu-devel@nongnu.org; Thu, 21 Feb 2019 13:58:00 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gwtXg-0007Mx-Eh for qemu-devel@nongnu.org; Thu, 21 Feb 2019 13:57:58 -0500 Received: from mail-wm1-x334.google.com ([2a00:1450:4864:20::334]:35614) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gwtXV-0007Gl-LK for qemu-devel@nongnu.org; Thu, 21 Feb 2019 13:57:49 -0500 Received: by mail-wm1-x334.google.com with SMTP id y15so10336961wma.0 for ; Thu, 21 Feb 2019 10:57:45 -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=xUAIzDpNWv8YnIShod0ImX2EP9PZydu99S3FvI92H14=; b=OZl0YjBvOAQF3KG4MZfX66qbuojlhuOXl/CFTrwNXKI9o704ydaYBoAyr78J7cqQap yqvwflfns70eDuFKxdJGske/+buqezPdtFJt/q+yk1eJyi75ZA++lv5pVMOcz7mOi0vh kOxlDkSdmnpaHCk9n7+3n48hzmmsHuWehMD0lG9sdQvce+s2sjYbkMK34DUPdi/s7wiF aEAgF8mLCHImfLVEz63I6ZHWqMxi2Nx9Y42WBso2g2LOEwyomez1x/qtmTSjIHFnkG4I Y0plNVssbiXQ35qrupItiMmcaRljHohERN+KCH/B2qeZPmQ/odzCctdtyvVtAJQ0gNHm V+2g== 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=xUAIzDpNWv8YnIShod0ImX2EP9PZydu99S3FvI92H14=; b=cMP5OJ6ZYdL/iWZVjQiWk17RZerd8rBk3DEQYR7YS2NKwZpb8vFaWk60qvsxpPRTPj ge53CNv1x1ntfo7PMvNI4ouATb/0CN8bhTl3rVZqDsZ6PHDCs3yTmcRGsVFlBdgc4Dvc N+PjtNEflSzhqFYLGeUhDa1WGaYKsqqd1ijuJ3hEfjFVbGu47rrCitCL1B/S3dF7Mi1T 89niI0bEv2a6UDF8GrUdUvaOTftIVZHlC9cb87MJuoUpyvlbPZPvmthhPkmRvbNh85xH 1m3pErJYCw93HkGL1VEwnWYan4lOROIkGEOx+V8YL8+JnMg2OrAYSwXxiLMGLuenQeHp taiA== X-Gm-Message-State: AHQUAua3V+ihSK5ETp8WC5GdZIwY1wStN1vpnl99xe73Uv8kaCm9Iuy5 uwz81hfJHbFgtcBdBHXlWESqPgq7hMw= X-Received: by 2002:a1c:3b06:: with SMTP id i6mr11298854wma.55.1550775464293; Thu, 21 Feb 2019 10:57:44 -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.57.43 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 21 Feb 2019 10:57:43 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Date: Thu, 21 Feb 2019 18:57:20 +0000 Message-Id: <20190221185739.25362-3-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::334 Subject: [Qemu-devel] [PULL 02/21] target/arm: v8M MPU should use background region as default, not always X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" The "background region" for a v8M MPU is a default which will be used (if enabled, and if the access is privileged) if the access does not match any specific MPU region. We were incorrectly using it always (by putting the condition at the wrong nesting level). This meant that we would always return the default background permissions rather than the correct permissions for a specific region, and also that we would not return the right information in response to a TT instruction. Move the check for the background region to the same place in the logic as the equivalent v8M MPUCheck() pseudocode puts it. This in turn means we must adjust the condition we use to detect matches in multiple regions to avoid false-positives. Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson Message-id: 20190214113408.10214-1-peter.maydell@linaro.org --- target/arm/helper.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) -- 2.20.1 diff --git a/target/arm/helper.c b/target/arm/helper.c index a018eb23fe2..fe054897c78 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -11387,9 +11387,11 @@ static bool pmsav8_mpu_lookup(CPUARMState *env, uint32_t address, 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 { + if (pmsav7_use_background_region(cpu, mmu_idx, is_user)) { + hit = true; + } + for (n = (int)cpu->pmsav7_dregion - 1; n >= 0; n--) { /* region search */ /* Note that the base address is bits [31:5] from the register @@ -11427,7 +11429,7 @@ static bool pmsav8_mpu_lookup(CPUARMState *env, uint32_t address, *is_subpage = true; } - if (hit) { + if (matchregion != -1) { /* Multiple regions match -- always a failure (unlike * PMSAv7 where highest-numbered-region wins) */ From patchwork Thu Feb 21 18:57:21 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 158935 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp837244jaa; Thu, 21 Feb 2019 11:03:13 -0800 (PST) X-Google-Smtp-Source: AHgI3IYk5liBMYYJKxbMh9LmP8BlpcS+hqgxaFxSTR/JK4XNcZ5xEV+ebaFyhCZ0ufDeaOnlGHDZ X-Received: by 2002:ac8:26ea:: with SMTP id 39mr33602071qtp.351.1550775793575; Thu, 21 Feb 2019 11:03:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550775793; cv=none; d=google.com; s=arc-20160816; b=FfMwRHol8hO/mdxk8UJ5V8qZ6S/lrM/jHHzKwZ/BmAbQ7janKhRBxPUxqSP0jc1Vr3 4M0nTzZgSBG+4F4YLmM/Yp6JjmDxMvdGMceXjbMsZEVscD9VL437Y19GLsUy0QGxnO2z tMhxlyOk15lueTUYUk0WzMhH++hFxwYTBK0y0nzzsQu2waXeBlaIbjqs7baL4eJABFrQ oZA62qZubAvkedNPGroPr9Wa/lYslXBY7tNFCt99Jo3V3BzRMxd4uHd7EN/lE7yktNG7 H014aPY/bJMbCT7RgDA56Vi60NP5lkF+5fEWezzmJQ/7EkTUAvU0t+Tvvdbr9N3lGbdn QaeQ== 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=nIehuVRXgnY3rhKhPHuNiPjunbQ4Fl2spBEKFWr6ckI=; b=YSXuUpahNtLT8pDyKDaI0NFu+aD+MUNhict5BrEeT7l91J52jMWI6dHYXSbWEI38lO nTykZjoMxr7sEJ3LLoXUxRtHH7kkGUR27bGXSij6K/2jgmq0L3PITqK52O49nXZ4B1r2 PuWw1Gh3giXJ+FCCrH40bUY9j/8t90ECLcgCZLYEWg2Bv55SMdFaCVcI+OqUoHmZpbG7 Upc58nS9u1vu6By86EfzoG+Be/yqZay6/RY13quhcRFPftUF7Sf7D2DRYp4p+5Z0Xijj Jtm0WK45xBAC/v94oRyQIZt7zLs8vncz1Xh9pnDpoKj8CMp+McUY0H4iZODjsQ1qJ+Yx hwEg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=LMIUQU+J; 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 x63si12950013ybx.217.2019.02.21.11.03.13 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 21 Feb 2019 11:03:13 -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=LMIUQU+J; 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]:36933 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwtcn-00043Q-2e for patch@linaro.org; Thu, 21 Feb 2019 14:03:13 -0500 Received: from eggs.gnu.org ([209.51.188.92]:52101) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwtXo-0008S2-UQ for qemu-devel@nongnu.org; Thu, 21 Feb 2019 13:58:05 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gwtXn-0007Qv-1h for qemu-devel@nongnu.org; Thu, 21 Feb 2019 13:58:04 -0500 Received: from mail-wm1-x32e.google.com ([2a00:1450:4864:20::32e]:54422) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gwtXl-0007HA-4E for qemu-devel@nongnu.org; Thu, 21 Feb 2019 13:58:02 -0500 Received: by mail-wm1-x32e.google.com with SMTP id a62so10640227wmh.4 for ; Thu, 21 Feb 2019 10:57:46 -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=nIehuVRXgnY3rhKhPHuNiPjunbQ4Fl2spBEKFWr6ckI=; b=LMIUQU+JyIyc9eNnNjnDlMfJevRS9cTeuepOTygmWxeiVxbppwG5Bzpa/e8cb6tgrv /5O7gNXA+jaxh4MoFcIhOV4BRP5RmlKhhWcEp/nVYS7ocNQoIr/Llg9jo23nQ6BiFxNC w5DIu7BbsouIKAiIW8+nj512G8Is2t2+SQ50uaAzgmovyOqIXQFnAIQF4iJZvCEI7ncn xsUXHYEyn95bI4d22v/jzS2j/hMpRcN9VR3KHCKdHnNBnIsZOH1y1Z9ly+iAMptRexyR aWAl8ugB9L35LM8xceCY/zToyMyx7aMSZv3XjnPDxydVqYSsK3w86HR+T2limxmEMHPh iJGQ== 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=nIehuVRXgnY3rhKhPHuNiPjunbQ4Fl2spBEKFWr6ckI=; b=DdvH5UhktmLWvdxzMdGbMUdfQ5+EYZLUNw1eBLUNsmpNNIoOB0a2saHrb690LPZ916 AKmUJJ9JMT2iSMoX6IyK5DgKNkvLAvQ/SXrjINlDUEC6LtHMMhy8t/wiyVT/kVN625/Z 6bQSGRA2PsvjdEopnqtdYadZWMp1SRmCkv1sFy3qoJX2TcXVJtF/qwUHvr5Rqw+JoWF4 bxRTFPSjZlqYFWsQErZ/N2W5IziJBxiN9FUGuDbapzQaAPMyhGpE8r2VW1lVkvwA6Prn SSNd/vYBUs7qiiLRpuZ0yI/4g41AHfvxOkKK6SoTmJ5J1o7Uv0o3k7paKuOUqLsc1XQ5 mpdA== X-Gm-Message-State: AHQUAubId1a+kfsfjc3dITgRF0OnVCXTccc0UG1VIofnGJUiDuVMzh67 kn8/IysVWTruiyVXR/lBApeJk20ziWg= X-Received: by 2002:a1c:4406:: with SMTP id r6mr12951wma.114.1550775465356; Thu, 21 Feb 2019 10:57:45 -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.57.44 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 21 Feb 2019 10:57:44 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Date: Thu, 21 Feb 2019 18:57:21 +0000 Message-Id: <20190221185739.25362-4-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::32e Subject: [Qemu-devel] [PULL 03/21] target/arm: Stop unintentional sign extension in pmu_init 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: Aaron Lindsay OS This was introduced by commit bf8d09694ccc07487cd73d7562081fdaec3370c8 target/arm: Don't clear supported PMU events when initializing PMCEID1 and identified by Coverity (CID 1398645). Signed-off-by: Aaron Lindsay Reported-by: Peter Maydell Message-id: 20190219144621.450-1-aaron@os.amperecomputing.com Reviewed-by: Peter Maydell Signed-off-by: Peter Maydell --- target/arm/helper.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.20.1 diff --git a/target/arm/helper.c b/target/arm/helper.c index fe054897c78..c2630fa1ea4 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -1167,7 +1167,7 @@ void pmu_init(ARMCPU *cpu) if (cnt->supported(&cpu->env)) { supported_event_map[cnt->number] = i; - uint64_t event_mask = 1 << (cnt->number & 0x1f); + uint64_t event_mask = 1ULL << (cnt->number & 0x1f); if (cnt->number & 0x20) { cpu->pmceid1 |= event_mask; } else { From patchwork Thu Feb 21 18:57:22 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 158942 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp844598jaa; Thu, 21 Feb 2019 11:09:53 -0800 (PST) X-Google-Smtp-Source: AHgI3IbbsztEdBt4TCn+5AEXG8LzWxJNYpkCmXFjU+whhy84iamF5XuSxVfArCCQ1+iP8rflgEBE X-Received: by 2002:a5b:9c2:: with SMTP id y2mr42351ybq.319.1550776193460; Thu, 21 Feb 2019 11:09:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550776193; cv=none; d=google.com; s=arc-20160816; b=tqX9pjwaixVeVcHS9YwyfqmkgC+eEZv23ntNgGiQ+kc2VEsnleuLBLMVW/u9DyEbx9 8r/x+qJ5bjxDJe3sWBPkhqe4ZmO6eL85+x8yTKpg7MyvpzmQFbTgl0ektA4r2nsAyG2n jYYuobDbFBmiMLl05M0Al6ufIzuJKqo0wozOK6BUrNdyEnRbuVslBuf6a8su7dSH6MFs 84UFRKHYABd8RQnLneaTSLWu+W8T4xIQwFHfd/43TK2+ikyzx5SqTaTEq8HNnSanLje/ 2xxpKCxDzZAs8brh55nek5DQGyz+ZZUcTKFnSxycM/PM1FAVg1qAZzbyU8k8CJl/B/eb vF2A== 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=fcFwP6kgL8uSzXhgIr8LZ9mznClXvotYfvlQAXBxjlQ=; b=Hk0U1Bxs7UBp+D8PUYg13Toa4prT7tuuhxWeR7HQ/DnxPxsGgmVVaxfrXKje5xCmmg CPbZ174uTQGUNlFmDg/a0++T+dM03npkvtsQo+nyItQN+LXmbIexMkeBtJEH5/MaIKT+ CzLrrVOk6dMIKuN9XU9RVtIlGoWPByR4SQ2Dv2vwcPy5zslDy8Tt4gWv4ZlcJHPGTBsQ /Q+N1UshgDZ3dCFUdOQXTJ/eKvPj9BppYUenXOi8dbdzxP7N0ijM5MwzgFVLSpH4+nx6 DhEA0+6GRPIJ2bHfrWupvAOA/PXyC6JlqmtCIcKfBmGPoPA4/QUGMti77j1kSvESlmP7 uOHQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b="s/09hg3A"; 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 p206si1102260yba.350.2019.02.21.11.09.53 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 21 Feb 2019 11:09:53 -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="s/09hg3A"; 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]:37020 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwtjE-00029T-Sg for patch@linaro.org; Thu, 21 Feb 2019 14:09:52 -0500 Received: from eggs.gnu.org ([209.51.188.92]:52066) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwtXn-0008QI-18 for qemu-devel@nongnu.org; Thu, 21 Feb 2019 13:58:03 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gwtXl-0007PW-54 for qemu-devel@nongnu.org; Thu, 21 Feb 2019 13:58:02 -0500 Received: from mail-wr1-x42e.google.com ([2a00:1450:4864:20::42e]:44724) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gwtXj-0007He-7r for qemu-devel@nongnu.org; Thu, 21 Feb 2019 13:58:01 -0500 Received: by mail-wr1-x42e.google.com with SMTP id w2so17186777wrt.11 for ; Thu, 21 Feb 2019 10:57:47 -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=fcFwP6kgL8uSzXhgIr8LZ9mznClXvotYfvlQAXBxjlQ=; b=s/09hg3Av/MzhQX2mxLEKLaj6JNCNsNc/i6sob4havVL+IVeaQYTSFZlGaEgtuwSAt onQcA8O5F5vqoIZPuiNrkZbDAh0HLHYB1ATP3Zmt/3XxN7NSEwb4tH5wgjnkT7oWb0nA uNIvbgmzcjbqZPSZFerv1xqGlDxN/DgUWmXMHilQ1KZec6a6AN7Mku+aq++L+3kV0UdY UvxxoGht1wVlbMa4Sc0qckn5FDthjSdSflJGU2tIeNjRWM2Vbx10Xg8pi7QnrQ4Srme8 /yg5KGiJkFqe9Sr3/0VRhd47qAOyqldlKw0sUWfe/Qd1HeOi6JIsXneniVifhep9MdXT zHQg== 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=fcFwP6kgL8uSzXhgIr8LZ9mznClXvotYfvlQAXBxjlQ=; b=tXMFKqPQD+831PTn7fOEBEOQiMw2eqFPtMti0FCv6er4YeqGul89+RvW8gO3/lC1zN FPzTO8wRB0tdTtHuTjooiXJwpOhrwGEk54Xqq0R6V3kJkpW4WCiSHi0bcuDg0bcLjoAR 4AGUdJGRa7U32GldZ4sBP6fpoyY+MtIpRvSkmIbbyL6oL2Y4uJdZHBkskq/9ab4bwxGh eLDfo9DInZ1d9FjdEUt3eyclNLH8g4dhVSF6q9StsfsMu52sTqasSskrg1D5Y65Tdj9n 8wqDs/6j6s/YZP2RRmRg6iEG0CChQSetyCeaaETxHOz2Rh2YxNBp3F2MvPd8TEcCMv5v Itaw== X-Gm-Message-State: AHQUAuYx4fye2MYIz3Xt/jY0+oFMHn8KDwEvmS0/SF2ScC0DVwZxuZUA 2v8Hg0YjqGqUPZ0+fhLH3VmYRHPTzWo= X-Received: by 2002:a5d:4841:: with SMTP id n1mr28569313wrs.85.1550775466577; Thu, 21 Feb 2019 10:57:46 -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.57.45 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 21 Feb 2019 10:57:45 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Date: Thu, 21 Feb 2019 18:57:22 +0000 Message-Id: <20190221185739.25362-5-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::42e Subject: [Qemu-devel] [PULL 04/21] target/arm: Restructure disas_fp_int_conv X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson For opcodes 0-5, move some if conditions into the structure of a switch statement. For opcodes 6 & 7, decode everything at once with a second switch. Signed-off-by: Richard Henderson Message-id: 20190215192302.27855-2-richard.henderson@linaro.org Reviewed-by: Peter Maydell Signed-off-by: Peter Maydell --- target/arm/translate-a64.c | 94 ++++++++++++++++++++------------------ 1 file changed, 49 insertions(+), 45 deletions(-) -- 2.20.1 diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c index af8e4fd4be1..dbce24fe32c 100644 --- a/target/arm/translate-a64.c +++ b/target/arm/translate-a64.c @@ -6541,68 +6541,72 @@ static void disas_fp_int_conv(DisasContext *s, uint32_t insn) int type = extract32(insn, 22, 2); bool sbit = extract32(insn, 29, 1); bool sf = extract32(insn, 31, 1); + bool itof = false; if (sbit) { - unallocated_encoding(s); - return; + goto do_unallocated; } - if (opcode > 5) { - /* FMOV */ - bool itof = opcode & 1; - - if (rmode >= 2) { - unallocated_encoding(s); - return; - } - - switch (sf << 3 | type << 1 | rmode) { - case 0x0: /* 32 bit */ - case 0xa: /* 64 bit */ - case 0xd: /* 64 bit to top half of quad */ - break; - case 0x6: /* 16-bit float, 32-bit int */ - case 0xe: /* 16-bit float, 64-bit int */ - if (dc_isar_feature(aa64_fp16, s)) { - break; - } - /* fallthru */ - default: - /* all other sf/type/rmode combinations are invalid */ - unallocated_encoding(s); - return; - } - - if (!fp_access_check(s)) { - return; - } - handle_fmov(s, rd, rn, type, itof); - } else { - /* actual FP conversions */ - bool itof = extract32(opcode, 1, 1); - - if (rmode != 0 && opcode > 1) { - unallocated_encoding(s); - return; + switch (opcode) { + case 2: /* SCVTF */ + case 3: /* UCVTF */ + itof = true; + /* fallthru */ + case 4: /* FCVTAS */ + case 5: /* FCVTAU */ + if (rmode != 0) { + goto do_unallocated; } + /* fallthru */ + case 0: /* FCVT[NPMZ]S */ + case 1: /* FCVT[NPMZ]U */ switch (type) { case 0: /* float32 */ case 1: /* float64 */ break; case 3: /* float16 */ - if (dc_isar_feature(aa64_fp16, s)) { - break; + if (!dc_isar_feature(aa64_fp16, s)) { + goto do_unallocated; } - /* fallthru */ + break; default: - unallocated_encoding(s); - return; + goto do_unallocated; } - if (!fp_access_check(s)) { return; } handle_fpfpcvt(s, rd, rn, opcode, itof, rmode, 64, sf, type); + break; + + default: + switch (sf << 7 | type << 5 | rmode << 3 | opcode) { + case 0b01100110: /* FMOV half <-> 32-bit int */ + case 0b01100111: + case 0b11100110: /* FMOV half <-> 64-bit int */ + case 0b11100111: + if (!dc_isar_feature(aa64_fp16, s)) { + goto do_unallocated; + } + /* fallthru */ + case 0b00000110: /* FMOV 32-bit */ + case 0b00000111: + case 0b10100110: /* FMOV 64-bit */ + case 0b10100111: + case 0b11001110: /* FMOV top half of 128-bit */ + case 0b11001111: + if (!fp_access_check(s)) { + return; + } + itof = opcode & 1; + handle_fmov(s, rd, rn, type, itof); + break; + + default: + do_unallocated: + unallocated_encoding(s); + return; + } + break; } } From patchwork Thu Feb 21 18:57:23 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 158947 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp848194jaa; Thu, 21 Feb 2019 11:13:24 -0800 (PST) X-Google-Smtp-Source: AHgI3Ib35cXHCAfHRXi+YdF4TWZBpSUXSysua9IO7K9nEiQ3A97ZMImWmkDw2dEv/uC03gpNGJk4 X-Received: by 2002:a81:6c4e:: with SMTP id h75mr84749ywc.206.1550776404565; Thu, 21 Feb 2019 11:13:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550776404; cv=none; d=google.com; s=arc-20160816; b=q6itCXrI7QaI5lhwZkuDMDuhSY/z6v18DClWTWm20XYfRbfDrnnCQWVzXEAe63tyYW JHiCES85Tp6OYgDcVuXBSADEc+EPpos5b6vRcTzZfI4S4TISjyPWKfGoTwnUYT3vKc6Y 8MtuCvaTwtoT5RjG+IN5arYOYXMaJPRw1QjxHEzLGosWLoUFm6x0lAjYYNBjUeU/CqKK tJDHhx4+vYxZ/My7Vym8sIDzS6mIT9+SrV00EVqiNvFS+dl8hocwVQApNGNVIyRsFsUv 8PNLWD8jbYmgpNTfz39hxWg3dSLLXnxkWwkwZRNL7uJpLbKS7FZsOoh73dJR7oh9lfZC HnvA== 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=dZ/+T4bxzwa9S4BptM1yLadbCaMLzNORalzkgi4hzME=; b=hi8mSQASbvMeHlLTP3pkksXAm088qtFrLWlZKwCfmyhTUSxMSNN84CyxQ9ERHuxyqy BoEl7/w/AgnmXKtHCkbsQww0aTXR89hrN4VT6acjtAYtWDdabWLbWmkdawfEKlxVmi9A vqDbAGxgVsMjnn1Q7K2WPB1smK/sOr2MMUM1x8RgWMcgKJS5r+YTd/SBQeMfua+3vlzS zLnKLgeAPF9pPWdkRfGkEjJ117/hDnjjuJn6qcXjipixUyMvd0utiWAVpSFhGdAyfV4f nmic8vb7SrrYRGR82E20bd/8FzsAPE38yaIy8HGA2ohxBLE9hzj1Psuhmy6TZdj/dw/F ao6Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=jYt+uEgg; 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 x76si8082782ybg.490.2019.02.21.11.13.24 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 21 Feb 2019 11:13:24 -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=jYt+uEgg; 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]:37078 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwtmd-00051o-QT for patch@linaro.org; Thu, 21 Feb 2019 14:13:23 -0500 Received: from eggs.gnu.org ([209.51.188.92]:52341) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwtXw-00008n-Da for qemu-devel@nongnu.org; Thu, 21 Feb 2019 13:58:18 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gwtXm-0007QY-Sx for qemu-devel@nongnu.org; Thu, 21 Feb 2019 13:58:12 -0500 Received: from mail-wr1-x436.google.com ([2a00:1450:4864:20::436]:43884) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gwtXj-0007JK-7u for qemu-devel@nongnu.org; Thu, 21 Feb 2019 13:58:01 -0500 Received: by mail-wr1-x436.google.com with SMTP id d17so17368415wre.10 for ; Thu, 21 Feb 2019 10:57:52 -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=dZ/+T4bxzwa9S4BptM1yLadbCaMLzNORalzkgi4hzME=; b=jYt+uEggTi4biMyewgHx+/5Z7EMP4BGGyvPmmSQDPSJ4utpGkQbBOKPnbcvl/mJH6q t1dF5HMLqUp312nGbr8LJjeK6Z40lniv4rZ66MlortH0+Ef5Xarzww++vsQ+skFGLANB mdXgb4sc/jEUkDuOqy6aoQLijHN27D2X/uvizf+334N4jCFuS4ExCLrLIjBvZMYBPciE 02dTnP/40kSFtucpfmaWZGpLrwFtlCJ3UjKq0Y/Ib9A9K59L5BwOG3LiquhI/kGLzDbo eFLGi2iPyldYMgd8EU6IX6Mow/fllJAjBCiTzKg9GIR2i9jmReq7qXMHxcz4N/sr7LHt SS4w== 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=dZ/+T4bxzwa9S4BptM1yLadbCaMLzNORalzkgi4hzME=; b=om9x2jDyT4wquJ4zU8fgNgZ33SvQ+lfQIsGK26sVuCcLxPCMwoSloHJQ3ebUHPJ6D8 5blqtD9XCnqkptU84ofQVbAsMtiqNp7O+ddwWiEZJbbhvX11xXcxDaeECmDTsHt5ECwn Edn/dpeje8IHQkge9Ijai4q1+EMlMIEBw9PBRoqhQphaRxu+YuY+PjMA7NTEkjuOTrb1 9zu58u0vMVUxmkfFCS8XBXbKpvodFgKo9A7mNQ4ShD0b8jo5pZHvo9gYG7k4FYiJGo+w 2oIU1ohMEKJAp2/UMLQXHl1paqmZIDAneyh6QUUu9mPwE4yN9AShrbZMVrF64Nnx0umC LMtw== X-Gm-Message-State: AHQUAua9FMITBTvdkyTf2OyINIoNQ3pkwj2rNGvm7h9YF08QTClQmWL8 NlXYjn0YDPhTJ5TEEqv4cRocYlT7VMs= X-Received: by 2002:a5d:44c3:: with SMTP id z3mr3415786wrr.329.1550775469727; Thu, 21 Feb 2019 10:57:49 -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.57.46 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 21 Feb 2019 10:57:48 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Date: Thu, 21 Feb 2019 18:57:23 +0000 Message-Id: <20190221185739.25362-6-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::436 Subject: [Qemu-devel] [PULL 05/21] target/arm: Split out vfp_helper.c X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson Move all of the fp helpers out of helper.c into a new file. This is code movement only. Since helper.c has no copyright header, take the one from cpu.h for the new file. Signed-off-by: Richard Henderson Message-id: 20190215192302.27855-3-richard.henderson@linaro.org Reviewed-by: Peter Maydell Signed-off-by: Peter Maydell --- target/arm/Makefile.objs | 2 +- target/arm/helper.c | 1062 ------------------------------------- target/arm/vfp_helper.c | 1088 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 1089 insertions(+), 1063 deletions(-) create mode 100644 target/arm/vfp_helper.c -- 2.20.1 diff --git a/target/arm/Makefile.objs b/target/arm/Makefile.objs index 1a4fc06448d..6bdcc65c2c8 100644 --- a/target/arm/Makefile.objs +++ b/target/arm/Makefile.objs @@ -5,7 +5,7 @@ obj-$(call land,$(CONFIG_KVM),$(call lnot,$(TARGET_AARCH64))) += kvm32.o obj-$(call land,$(CONFIG_KVM),$(TARGET_AARCH64)) += kvm64.o obj-$(call lnot,$(CONFIG_KVM)) += kvm-stub.o obj-y += translate.o op_helper.o helper.o cpu.o -obj-y += neon_helper.o iwmmxt_helper.o vec_helper.o +obj-y += neon_helper.o iwmmxt_helper.o vec_helper.o vfp_helper.o obj-y += gdbstub.o obj-$(TARGET_AARCH64) += cpu64.o translate-a64.o helper-a64.o gdbstub64.o obj-$(TARGET_AARCH64) += pauth_helper.o diff --git a/target/arm/helper.c b/target/arm/helper.c index c2630fa1ea4..fbaa801ceaa 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -12681,1068 +12681,6 @@ uint32_t HELPER(sel_flags)(uint32_t flags, uint32_t a, uint32_t b) return (a & mask) | (b & ~mask); } -/* VFP support. We follow the convention used for VFP instructions: - Single precision routines have a "s" suffix, double precision a - "d" suffix. */ - -/* Convert host exception flags to vfp form. */ -static inline int vfp_exceptbits_from_host(int host_bits) -{ - int target_bits = 0; - - if (host_bits & float_flag_invalid) - target_bits |= 1; - if (host_bits & float_flag_divbyzero) - target_bits |= 2; - if (host_bits & float_flag_overflow) - target_bits |= 4; - if (host_bits & (float_flag_underflow | float_flag_output_denormal)) - target_bits |= 8; - if (host_bits & float_flag_inexact) - target_bits |= 0x10; - if (host_bits & float_flag_input_denormal) - target_bits |= 0x80; - return target_bits; -} - -uint32_t HELPER(vfp_get_fpscr)(CPUARMState *env) -{ - uint32_t i, fpscr; - - fpscr = env->vfp.xregs[ARM_VFP_FPSCR] - | (env->vfp.vec_len << 16) - | (env->vfp.vec_stride << 20); - - i = get_float_exception_flags(&env->vfp.fp_status); - i |= get_float_exception_flags(&env->vfp.standard_fp_status); - /* FZ16 does not generate an input denormal exception. */ - i |= (get_float_exception_flags(&env->vfp.fp_status_f16) - & ~float_flag_input_denormal); - fpscr |= vfp_exceptbits_from_host(i); - - i = env->vfp.qc[0] | env->vfp.qc[1] | env->vfp.qc[2] | env->vfp.qc[3]; - fpscr |= i ? FPCR_QC : 0; - - return fpscr; -} - -uint32_t vfp_get_fpscr(CPUARMState *env) -{ - return HELPER(vfp_get_fpscr)(env); -} - -/* Convert vfp exception flags to target form. */ -static inline int vfp_exceptbits_to_host(int target_bits) -{ - int host_bits = 0; - - if (target_bits & 1) - host_bits |= float_flag_invalid; - if (target_bits & 2) - host_bits |= float_flag_divbyzero; - if (target_bits & 4) - host_bits |= float_flag_overflow; - if (target_bits & 8) - host_bits |= float_flag_underflow; - if (target_bits & 0x10) - host_bits |= float_flag_inexact; - if (target_bits & 0x80) - host_bits |= float_flag_input_denormal; - return host_bits; -} - -void HELPER(vfp_set_fpscr)(CPUARMState *env, uint32_t val) -{ - int i; - uint32_t changed = env->vfp.xregs[ARM_VFP_FPSCR]; - - /* When ARMv8.2-FP16 is not supported, FZ16 is RES0. */ - if (!cpu_isar_feature(aa64_fp16, arm_env_get_cpu(env))) { - val &= ~FPCR_FZ16; - } - - /* - * We don't implement trapped exception handling, so the - * trap enable bits, IDE|IXE|UFE|OFE|DZE|IOE are all RAZ/WI (not RES0!) - * - * If we exclude the exception flags, IOC|DZC|OFC|UFC|IXC|IDC - * (which are stored in fp_status), and the other RES0 bits - * in between, then we clear all of the low 16 bits. - */ - env->vfp.xregs[ARM_VFP_FPSCR] = val & 0xf7c80000; - env->vfp.vec_len = (val >> 16) & 7; - env->vfp.vec_stride = (val >> 20) & 3; - - /* - * The bit we set within fpscr_q is arbitrary; the register as a - * whole being zero/non-zero is what counts. - */ - env->vfp.qc[0] = val & FPCR_QC; - env->vfp.qc[1] = 0; - env->vfp.qc[2] = 0; - env->vfp.qc[3] = 0; - - changed ^= val; - if (changed & (3 << 22)) { - i = (val >> 22) & 3; - switch (i) { - case FPROUNDING_TIEEVEN: - i = float_round_nearest_even; - break; - case FPROUNDING_POSINF: - i = float_round_up; - break; - case FPROUNDING_NEGINF: - i = float_round_down; - break; - case FPROUNDING_ZERO: - i = float_round_to_zero; - break; - } - set_float_rounding_mode(i, &env->vfp.fp_status); - set_float_rounding_mode(i, &env->vfp.fp_status_f16); - } - if (changed & FPCR_FZ16) { - bool ftz_enabled = val & FPCR_FZ16; - set_flush_to_zero(ftz_enabled, &env->vfp.fp_status_f16); - set_flush_inputs_to_zero(ftz_enabled, &env->vfp.fp_status_f16); - } - if (changed & FPCR_FZ) { - bool ftz_enabled = val & FPCR_FZ; - set_flush_to_zero(ftz_enabled, &env->vfp.fp_status); - set_flush_inputs_to_zero(ftz_enabled, &env->vfp.fp_status); - } - if (changed & FPCR_DN) { - bool dnan_enabled = val & FPCR_DN; - set_default_nan_mode(dnan_enabled, &env->vfp.fp_status); - set_default_nan_mode(dnan_enabled, &env->vfp.fp_status_f16); - } - - /* The exception flags are ORed together when we read fpscr so we - * only need to preserve the current state in one of our - * float_status values. - */ - i = vfp_exceptbits_to_host(val); - set_float_exception_flags(i, &env->vfp.fp_status); - set_float_exception_flags(0, &env->vfp.fp_status_f16); - set_float_exception_flags(0, &env->vfp.standard_fp_status); -} - -void vfp_set_fpscr(CPUARMState *env, uint32_t val) -{ - HELPER(vfp_set_fpscr)(env, val); -} - -#define VFP_HELPER(name, p) HELPER(glue(glue(vfp_,name),p)) - -#define VFP_BINOP(name) \ -float32 VFP_HELPER(name, s)(float32 a, float32 b, void *fpstp) \ -{ \ - float_status *fpst = fpstp; \ - return float32_ ## name(a, b, fpst); \ -} \ -float64 VFP_HELPER(name, d)(float64 a, float64 b, void *fpstp) \ -{ \ - float_status *fpst = fpstp; \ - return float64_ ## name(a, b, fpst); \ -} -VFP_BINOP(add) -VFP_BINOP(sub) -VFP_BINOP(mul) -VFP_BINOP(div) -VFP_BINOP(min) -VFP_BINOP(max) -VFP_BINOP(minnum) -VFP_BINOP(maxnum) -#undef VFP_BINOP - -float32 VFP_HELPER(neg, s)(float32 a) -{ - return float32_chs(a); -} - -float64 VFP_HELPER(neg, d)(float64 a) -{ - return float64_chs(a); -} - -float32 VFP_HELPER(abs, s)(float32 a) -{ - return float32_abs(a); -} - -float64 VFP_HELPER(abs, d)(float64 a) -{ - return float64_abs(a); -} - -float32 VFP_HELPER(sqrt, s)(float32 a, CPUARMState *env) -{ - return float32_sqrt(a, &env->vfp.fp_status); -} - -float64 VFP_HELPER(sqrt, d)(float64 a, CPUARMState *env) -{ - return float64_sqrt(a, &env->vfp.fp_status); -} - -static void softfloat_to_vfp_compare(CPUARMState *env, int cmp) -{ - uint32_t flags; - switch (cmp) { - case float_relation_equal: - flags = 0x6; - break; - case float_relation_less: - flags = 0x8; - break; - case float_relation_greater: - flags = 0x2; - break; - case float_relation_unordered: - flags = 0x3; - break; - default: - g_assert_not_reached(); - } - env->vfp.xregs[ARM_VFP_FPSCR] = - deposit32(env->vfp.xregs[ARM_VFP_FPSCR], 28, 4, flags); -} - -/* XXX: check quiet/signaling case */ -#define DO_VFP_cmp(p, type) \ -void VFP_HELPER(cmp, p)(type a, type b, CPUARMState *env) \ -{ \ - softfloat_to_vfp_compare(env, \ - type ## _compare_quiet(a, b, &env->vfp.fp_status)); \ -} \ -void VFP_HELPER(cmpe, p)(type a, type b, CPUARMState *env) \ -{ \ - softfloat_to_vfp_compare(env, \ - type ## _compare(a, b, &env->vfp.fp_status)); \ -} -DO_VFP_cmp(s, float32) -DO_VFP_cmp(d, float64) -#undef DO_VFP_cmp - -/* Integer to float and float to integer conversions */ - -#define CONV_ITOF(name, ftype, fsz, sign) \ -ftype HELPER(name)(uint32_t x, void *fpstp) \ -{ \ - float_status *fpst = fpstp; \ - return sign##int32_to_##float##fsz((sign##int32_t)x, fpst); \ -} - -#define CONV_FTOI(name, ftype, fsz, sign, round) \ -sign##int32_t HELPER(name)(ftype x, void *fpstp) \ -{ \ - float_status *fpst = fpstp; \ - if (float##fsz##_is_any_nan(x)) { \ - float_raise(float_flag_invalid, fpst); \ - return 0; \ - } \ - return float##fsz##_to_##sign##int32##round(x, fpst); \ -} - -#define FLOAT_CONVS(name, p, ftype, fsz, sign) \ - CONV_ITOF(vfp_##name##to##p, ftype, fsz, sign) \ - CONV_FTOI(vfp_to##name##p, ftype, fsz, sign, ) \ - CONV_FTOI(vfp_to##name##z##p, ftype, fsz, sign, _round_to_zero) - -FLOAT_CONVS(si, h, uint32_t, 16, ) -FLOAT_CONVS(si, s, float32, 32, ) -FLOAT_CONVS(si, d, float64, 64, ) -FLOAT_CONVS(ui, h, uint32_t, 16, u) -FLOAT_CONVS(ui, s, float32, 32, u) -FLOAT_CONVS(ui, d, float64, 64, u) - -#undef CONV_ITOF -#undef CONV_FTOI -#undef FLOAT_CONVS - -/* floating point conversion */ -float64 VFP_HELPER(fcvtd, s)(float32 x, CPUARMState *env) -{ - return float32_to_float64(x, &env->vfp.fp_status); -} - -float32 VFP_HELPER(fcvts, d)(float64 x, CPUARMState *env) -{ - return float64_to_float32(x, &env->vfp.fp_status); -} - -/* VFP3 fixed point conversion. */ -#define VFP_CONV_FIX_FLOAT(name, p, fsz, isz, itype) \ -float##fsz HELPER(vfp_##name##to##p)(uint##isz##_t x, uint32_t shift, \ - void *fpstp) \ -{ return itype##_to_##float##fsz##_scalbn(x, -shift, fpstp); } - -#define VFP_CONV_FLOAT_FIX_ROUND(name, p, fsz, isz, itype, ROUND, suff) \ -uint##isz##_t HELPER(vfp_to##name##p##suff)(float##fsz x, uint32_t shift, \ - void *fpst) \ -{ \ - if (unlikely(float##fsz##_is_any_nan(x))) { \ - float_raise(float_flag_invalid, fpst); \ - return 0; \ - } \ - return float##fsz##_to_##itype##_scalbn(x, ROUND, shift, fpst); \ -} - -#define VFP_CONV_FIX(name, p, fsz, isz, itype) \ -VFP_CONV_FIX_FLOAT(name, p, fsz, isz, itype) \ -VFP_CONV_FLOAT_FIX_ROUND(name, p, fsz, isz, itype, \ - float_round_to_zero, _round_to_zero) \ -VFP_CONV_FLOAT_FIX_ROUND(name, p, fsz, isz, itype, \ - get_float_rounding_mode(fpst), ) - -#define VFP_CONV_FIX_A64(name, p, fsz, isz, itype) \ -VFP_CONV_FIX_FLOAT(name, p, fsz, isz, itype) \ -VFP_CONV_FLOAT_FIX_ROUND(name, p, fsz, isz, itype, \ - get_float_rounding_mode(fpst), ) - -VFP_CONV_FIX(sh, d, 64, 64, int16) -VFP_CONV_FIX(sl, d, 64, 64, int32) -VFP_CONV_FIX_A64(sq, d, 64, 64, int64) -VFP_CONV_FIX(uh, d, 64, 64, uint16) -VFP_CONV_FIX(ul, d, 64, 64, uint32) -VFP_CONV_FIX_A64(uq, d, 64, 64, uint64) -VFP_CONV_FIX(sh, s, 32, 32, int16) -VFP_CONV_FIX(sl, s, 32, 32, int32) -VFP_CONV_FIX_A64(sq, s, 32, 64, int64) -VFP_CONV_FIX(uh, s, 32, 32, uint16) -VFP_CONV_FIX(ul, s, 32, 32, uint32) -VFP_CONV_FIX_A64(uq, s, 32, 64, uint64) - -#undef VFP_CONV_FIX -#undef VFP_CONV_FIX_FLOAT -#undef VFP_CONV_FLOAT_FIX_ROUND -#undef VFP_CONV_FIX_A64 - -uint32_t HELPER(vfp_sltoh)(uint32_t x, uint32_t shift, void *fpst) -{ - return int32_to_float16_scalbn(x, -shift, fpst); -} - -uint32_t HELPER(vfp_ultoh)(uint32_t x, uint32_t shift, void *fpst) -{ - return uint32_to_float16_scalbn(x, -shift, fpst); -} - -uint32_t HELPER(vfp_sqtoh)(uint64_t x, uint32_t shift, void *fpst) -{ - return int64_to_float16_scalbn(x, -shift, fpst); -} - -uint32_t HELPER(vfp_uqtoh)(uint64_t x, uint32_t shift, void *fpst) -{ - return uint64_to_float16_scalbn(x, -shift, fpst); -} - -uint32_t HELPER(vfp_toshh)(uint32_t x, uint32_t shift, void *fpst) -{ - if (unlikely(float16_is_any_nan(x))) { - float_raise(float_flag_invalid, fpst); - return 0; - } - return float16_to_int16_scalbn(x, get_float_rounding_mode(fpst), - shift, fpst); -} - -uint32_t HELPER(vfp_touhh)(uint32_t x, uint32_t shift, void *fpst) -{ - if (unlikely(float16_is_any_nan(x))) { - float_raise(float_flag_invalid, fpst); - return 0; - } - return float16_to_uint16_scalbn(x, get_float_rounding_mode(fpst), - shift, fpst); -} - -uint32_t HELPER(vfp_toslh)(uint32_t x, uint32_t shift, void *fpst) -{ - if (unlikely(float16_is_any_nan(x))) { - float_raise(float_flag_invalid, fpst); - return 0; - } - return float16_to_int32_scalbn(x, get_float_rounding_mode(fpst), - shift, fpst); -} - -uint32_t HELPER(vfp_toulh)(uint32_t x, uint32_t shift, void *fpst) -{ - if (unlikely(float16_is_any_nan(x))) { - float_raise(float_flag_invalid, fpst); - return 0; - } - return float16_to_uint32_scalbn(x, get_float_rounding_mode(fpst), - shift, fpst); -} - -uint64_t HELPER(vfp_tosqh)(uint32_t x, uint32_t shift, void *fpst) -{ - if (unlikely(float16_is_any_nan(x))) { - float_raise(float_flag_invalid, fpst); - return 0; - } - return float16_to_int64_scalbn(x, get_float_rounding_mode(fpst), - shift, fpst); -} - -uint64_t HELPER(vfp_touqh)(uint32_t x, uint32_t shift, void *fpst) -{ - if (unlikely(float16_is_any_nan(x))) { - float_raise(float_flag_invalid, fpst); - return 0; - } - return float16_to_uint64_scalbn(x, get_float_rounding_mode(fpst), - shift, fpst); -} - -/* Set the current fp rounding mode and return the old one. - * The argument is a softfloat float_round_ value. - */ -uint32_t HELPER(set_rmode)(uint32_t rmode, void *fpstp) -{ - float_status *fp_status = fpstp; - - uint32_t prev_rmode = get_float_rounding_mode(fp_status); - set_float_rounding_mode(rmode, fp_status); - - return prev_rmode; -} - -/* Set the current fp rounding mode in the standard fp status and return - * the old one. This is for NEON instructions that need to change the - * rounding mode but wish to use the standard FPSCR values for everything - * else. Always set the rounding mode back to the correct value after - * modifying it. - * The argument is a softfloat float_round_ value. - */ -uint32_t HELPER(set_neon_rmode)(uint32_t rmode, CPUARMState *env) -{ - float_status *fp_status = &env->vfp.standard_fp_status; - - uint32_t prev_rmode = get_float_rounding_mode(fp_status); - set_float_rounding_mode(rmode, fp_status); - - return prev_rmode; -} - -/* Half precision conversions. */ -float32 HELPER(vfp_fcvt_f16_to_f32)(uint32_t a, void *fpstp, uint32_t ahp_mode) -{ - /* Squash FZ16 to 0 for the duration of conversion. In this case, - * it would affect flushing input denormals. - */ - float_status *fpst = fpstp; - flag save = get_flush_inputs_to_zero(fpst); - set_flush_inputs_to_zero(false, fpst); - float32 r = float16_to_float32(a, !ahp_mode, fpst); - set_flush_inputs_to_zero(save, fpst); - return r; -} - -uint32_t HELPER(vfp_fcvt_f32_to_f16)(float32 a, void *fpstp, uint32_t ahp_mode) -{ - /* Squash FZ16 to 0 for the duration of conversion. In this case, - * it would affect flushing output denormals. - */ - float_status *fpst = fpstp; - flag save = get_flush_to_zero(fpst); - set_flush_to_zero(false, fpst); - float16 r = float32_to_float16(a, !ahp_mode, fpst); - set_flush_to_zero(save, fpst); - return r; -} - -float64 HELPER(vfp_fcvt_f16_to_f64)(uint32_t a, void *fpstp, uint32_t ahp_mode) -{ - /* Squash FZ16 to 0 for the duration of conversion. In this case, - * it would affect flushing input denormals. - */ - float_status *fpst = fpstp; - flag save = get_flush_inputs_to_zero(fpst); - set_flush_inputs_to_zero(false, fpst); - float64 r = float16_to_float64(a, !ahp_mode, fpst); - set_flush_inputs_to_zero(save, fpst); - return r; -} - -uint32_t HELPER(vfp_fcvt_f64_to_f16)(float64 a, void *fpstp, uint32_t ahp_mode) -{ - /* Squash FZ16 to 0 for the duration of conversion. In this case, - * it would affect flushing output denormals. - */ - float_status *fpst = fpstp; - flag save = get_flush_to_zero(fpst); - set_flush_to_zero(false, fpst); - float16 r = float64_to_float16(a, !ahp_mode, fpst); - set_flush_to_zero(save, fpst); - return r; -} - -#define float32_two make_float32(0x40000000) -#define float32_three make_float32(0x40400000) -#define float32_one_point_five make_float32(0x3fc00000) - -float32 HELPER(recps_f32)(float32 a, float32 b, CPUARMState *env) -{ - float_status *s = &env->vfp.standard_fp_status; - if ((float32_is_infinity(a) && float32_is_zero_or_denormal(b)) || - (float32_is_infinity(b) && float32_is_zero_or_denormal(a))) { - if (!(float32_is_zero(a) || float32_is_zero(b))) { - float_raise(float_flag_input_denormal, s); - } - return float32_two; - } - return float32_sub(float32_two, float32_mul(a, b, s), s); -} - -float32 HELPER(rsqrts_f32)(float32 a, float32 b, CPUARMState *env) -{ - float_status *s = &env->vfp.standard_fp_status; - float32 product; - if ((float32_is_infinity(a) && float32_is_zero_or_denormal(b)) || - (float32_is_infinity(b) && float32_is_zero_or_denormal(a))) { - if (!(float32_is_zero(a) || float32_is_zero(b))) { - float_raise(float_flag_input_denormal, s); - } - return float32_one_point_five; - } - product = float32_mul(a, b, s); - return float32_div(float32_sub(float32_three, product, s), float32_two, s); -} - -/* NEON helpers. */ - -/* Constants 256 and 512 are used in some helpers; we avoid relying on - * int->float conversions at run-time. */ -#define float64_256 make_float64(0x4070000000000000LL) -#define float64_512 make_float64(0x4080000000000000LL) -#define float16_maxnorm make_float16(0x7bff) -#define float32_maxnorm make_float32(0x7f7fffff) -#define float64_maxnorm make_float64(0x7fefffffffffffffLL) - -/* Reciprocal functions - * - * The algorithm that must be used to calculate the estimate - * is specified by the ARM ARM, see FPRecipEstimate()/RecipEstimate - */ - -/* See RecipEstimate() - * - * input is a 9 bit fixed point number - * input range 256 .. 511 for a number from 0.5 <= x < 1.0. - * result range 256 .. 511 for a number from 1.0 to 511/256. - */ - -static int recip_estimate(int input) -{ - int a, b, r; - assert(256 <= input && input < 512); - a = (input * 2) + 1; - b = (1 << 19) / a; - r = (b + 1) >> 1; - assert(256 <= r && r < 512); - return r; -} - -/* - * Common wrapper to call recip_estimate - * - * The parameters are exponent and 64 bit fraction (without implicit - * bit) where the binary point is nominally at bit 52. Returns a - * float64 which can then be rounded to the appropriate size by the - * callee. - */ - -static uint64_t call_recip_estimate(int *exp, int exp_off, uint64_t frac) -{ - uint32_t scaled, estimate; - uint64_t result_frac; - int result_exp; - - /* Handle sub-normals */ - if (*exp == 0) { - if (extract64(frac, 51, 1) == 0) { - *exp = -1; - frac <<= 2; - } else { - frac <<= 1; - } - } - - /* scaled = UInt('1':fraction<51:44>) */ - scaled = deposit32(1 << 8, 0, 8, extract64(frac, 44, 8)); - estimate = recip_estimate(scaled); - - result_exp = exp_off - *exp; - result_frac = deposit64(0, 44, 8, estimate); - if (result_exp == 0) { - result_frac = deposit64(result_frac >> 1, 51, 1, 1); - } else if (result_exp == -1) { - result_frac = deposit64(result_frac >> 2, 50, 2, 1); - result_exp = 0; - } - - *exp = result_exp; - - return result_frac; -} - -static bool round_to_inf(float_status *fpst, bool sign_bit) -{ - switch (fpst->float_rounding_mode) { - case float_round_nearest_even: /* Round to Nearest */ - return true; - case float_round_up: /* Round to +Inf */ - return !sign_bit; - case float_round_down: /* Round to -Inf */ - return sign_bit; - case float_round_to_zero: /* Round to Zero */ - return false; - } - - g_assert_not_reached(); -} - -uint32_t HELPER(recpe_f16)(uint32_t input, void *fpstp) -{ - float_status *fpst = fpstp; - float16 f16 = float16_squash_input_denormal(input, fpst); - uint32_t f16_val = float16_val(f16); - uint32_t f16_sign = float16_is_neg(f16); - int f16_exp = extract32(f16_val, 10, 5); - uint32_t f16_frac = extract32(f16_val, 0, 10); - uint64_t f64_frac; - - if (float16_is_any_nan(f16)) { - float16 nan = f16; - if (float16_is_signaling_nan(f16, fpst)) { - float_raise(float_flag_invalid, fpst); - nan = float16_silence_nan(f16, fpst); - } - if (fpst->default_nan_mode) { - nan = float16_default_nan(fpst); - } - return nan; - } else if (float16_is_infinity(f16)) { - return float16_set_sign(float16_zero, float16_is_neg(f16)); - } else if (float16_is_zero(f16)) { - float_raise(float_flag_divbyzero, fpst); - return float16_set_sign(float16_infinity, float16_is_neg(f16)); - } else if (float16_abs(f16) < (1 << 8)) { - /* Abs(value) < 2.0^-16 */ - float_raise(float_flag_overflow | float_flag_inexact, fpst); - if (round_to_inf(fpst, f16_sign)) { - return float16_set_sign(float16_infinity, f16_sign); - } else { - return float16_set_sign(float16_maxnorm, f16_sign); - } - } else if (f16_exp >= 29 && fpst->flush_to_zero) { - float_raise(float_flag_underflow, fpst); - return float16_set_sign(float16_zero, float16_is_neg(f16)); - } - - f64_frac = call_recip_estimate(&f16_exp, 29, - ((uint64_t) f16_frac) << (52 - 10)); - - /* result = sign : result_exp<4:0> : fraction<51:42> */ - f16_val = deposit32(0, 15, 1, f16_sign); - f16_val = deposit32(f16_val, 10, 5, f16_exp); - f16_val = deposit32(f16_val, 0, 10, extract64(f64_frac, 52 - 10, 10)); - return make_float16(f16_val); -} - -float32 HELPER(recpe_f32)(float32 input, void *fpstp) -{ - float_status *fpst = fpstp; - float32 f32 = float32_squash_input_denormal(input, fpst); - uint32_t f32_val = float32_val(f32); - bool f32_sign = float32_is_neg(f32); - int f32_exp = extract32(f32_val, 23, 8); - uint32_t f32_frac = extract32(f32_val, 0, 23); - uint64_t f64_frac; - - if (float32_is_any_nan(f32)) { - float32 nan = f32; - if (float32_is_signaling_nan(f32, fpst)) { - float_raise(float_flag_invalid, fpst); - nan = float32_silence_nan(f32, fpst); - } - if (fpst->default_nan_mode) { - nan = float32_default_nan(fpst); - } - return nan; - } else if (float32_is_infinity(f32)) { - return float32_set_sign(float32_zero, float32_is_neg(f32)); - } else if (float32_is_zero(f32)) { - float_raise(float_flag_divbyzero, fpst); - return float32_set_sign(float32_infinity, float32_is_neg(f32)); - } else if (float32_abs(f32) < (1ULL << 21)) { - /* Abs(value) < 2.0^-128 */ - float_raise(float_flag_overflow | float_flag_inexact, fpst); - if (round_to_inf(fpst, f32_sign)) { - return float32_set_sign(float32_infinity, f32_sign); - } else { - return float32_set_sign(float32_maxnorm, f32_sign); - } - } else if (f32_exp >= 253 && fpst->flush_to_zero) { - float_raise(float_flag_underflow, fpst); - return float32_set_sign(float32_zero, float32_is_neg(f32)); - } - - f64_frac = call_recip_estimate(&f32_exp, 253, - ((uint64_t) f32_frac) << (52 - 23)); - - /* result = sign : result_exp<7:0> : fraction<51:29> */ - f32_val = deposit32(0, 31, 1, f32_sign); - f32_val = deposit32(f32_val, 23, 8, f32_exp); - f32_val = deposit32(f32_val, 0, 23, extract64(f64_frac, 52 - 23, 23)); - return make_float32(f32_val); -} - -float64 HELPER(recpe_f64)(float64 input, void *fpstp) -{ - float_status *fpst = fpstp; - float64 f64 = float64_squash_input_denormal(input, fpst); - uint64_t f64_val = float64_val(f64); - bool f64_sign = float64_is_neg(f64); - int f64_exp = extract64(f64_val, 52, 11); - uint64_t f64_frac = extract64(f64_val, 0, 52); - - /* Deal with any special cases */ - if (float64_is_any_nan(f64)) { - float64 nan = f64; - if (float64_is_signaling_nan(f64, fpst)) { - float_raise(float_flag_invalid, fpst); - nan = float64_silence_nan(f64, fpst); - } - if (fpst->default_nan_mode) { - nan = float64_default_nan(fpst); - } - return nan; - } else if (float64_is_infinity(f64)) { - return float64_set_sign(float64_zero, float64_is_neg(f64)); - } else if (float64_is_zero(f64)) { - float_raise(float_flag_divbyzero, fpst); - return float64_set_sign(float64_infinity, float64_is_neg(f64)); - } else if ((f64_val & ~(1ULL << 63)) < (1ULL << 50)) { - /* Abs(value) < 2.0^-1024 */ - float_raise(float_flag_overflow | float_flag_inexact, fpst); - if (round_to_inf(fpst, f64_sign)) { - return float64_set_sign(float64_infinity, f64_sign); - } else { - return float64_set_sign(float64_maxnorm, f64_sign); - } - } else if (f64_exp >= 2045 && fpst->flush_to_zero) { - float_raise(float_flag_underflow, fpst); - return float64_set_sign(float64_zero, float64_is_neg(f64)); - } - - f64_frac = call_recip_estimate(&f64_exp, 2045, f64_frac); - - /* result = sign : result_exp<10:0> : fraction<51:0>; */ - f64_val = deposit64(0, 63, 1, f64_sign); - f64_val = deposit64(f64_val, 52, 11, f64_exp); - f64_val = deposit64(f64_val, 0, 52, f64_frac); - return make_float64(f64_val); -} - -/* The algorithm that must be used to calculate the estimate - * is specified by the ARM ARM. - */ - -static int do_recip_sqrt_estimate(int a) -{ - int b, estimate; - - assert(128 <= a && a < 512); - if (a < 256) { - a = a * 2 + 1; - } else { - a = (a >> 1) << 1; - a = (a + 1) * 2; - } - b = 512; - while (a * (b + 1) * (b + 1) < (1 << 28)) { - b += 1; - } - estimate = (b + 1) / 2; - assert(256 <= estimate && estimate < 512); - - return estimate; -} - - -static uint64_t recip_sqrt_estimate(int *exp , int exp_off, uint64_t frac) -{ - int estimate; - uint32_t scaled; - - if (*exp == 0) { - while (extract64(frac, 51, 1) == 0) { - frac = frac << 1; - *exp -= 1; - } - frac = extract64(frac, 0, 51) << 1; - } - - if (*exp & 1) { - /* scaled = UInt('01':fraction<51:45>) */ - scaled = deposit32(1 << 7, 0, 7, extract64(frac, 45, 7)); - } else { - /* scaled = UInt('1':fraction<51:44>) */ - scaled = deposit32(1 << 8, 0, 8, extract64(frac, 44, 8)); - } - estimate = do_recip_sqrt_estimate(scaled); - - *exp = (exp_off - *exp) / 2; - return extract64(estimate, 0, 8) << 44; -} - -uint32_t HELPER(rsqrte_f16)(uint32_t input, void *fpstp) -{ - float_status *s = fpstp; - float16 f16 = float16_squash_input_denormal(input, s); - uint16_t val = float16_val(f16); - bool f16_sign = float16_is_neg(f16); - int f16_exp = extract32(val, 10, 5); - uint16_t f16_frac = extract32(val, 0, 10); - uint64_t f64_frac; - - if (float16_is_any_nan(f16)) { - float16 nan = f16; - if (float16_is_signaling_nan(f16, s)) { - float_raise(float_flag_invalid, s); - nan = float16_silence_nan(f16, s); - } - if (s->default_nan_mode) { - nan = float16_default_nan(s); - } - return nan; - } else if (float16_is_zero(f16)) { - float_raise(float_flag_divbyzero, s); - return float16_set_sign(float16_infinity, f16_sign); - } else if (f16_sign) { - float_raise(float_flag_invalid, s); - return float16_default_nan(s); - } else if (float16_is_infinity(f16)) { - return float16_zero; - } - - /* Scale and normalize to a double-precision value between 0.25 and 1.0, - * preserving the parity of the exponent. */ - - f64_frac = ((uint64_t) f16_frac) << (52 - 10); - - f64_frac = recip_sqrt_estimate(&f16_exp, 44, f64_frac); - - /* result = sign : result_exp<4:0> : estimate<7:0> : Zeros(2) */ - val = deposit32(0, 15, 1, f16_sign); - val = deposit32(val, 10, 5, f16_exp); - val = deposit32(val, 2, 8, extract64(f64_frac, 52 - 8, 8)); - return make_float16(val); -} - -float32 HELPER(rsqrte_f32)(float32 input, void *fpstp) -{ - float_status *s = fpstp; - float32 f32 = float32_squash_input_denormal(input, s); - uint32_t val = float32_val(f32); - uint32_t f32_sign = float32_is_neg(f32); - int f32_exp = extract32(val, 23, 8); - uint32_t f32_frac = extract32(val, 0, 23); - uint64_t f64_frac; - - if (float32_is_any_nan(f32)) { - float32 nan = f32; - if (float32_is_signaling_nan(f32, s)) { - float_raise(float_flag_invalid, s); - nan = float32_silence_nan(f32, s); - } - if (s->default_nan_mode) { - nan = float32_default_nan(s); - } - return nan; - } else if (float32_is_zero(f32)) { - float_raise(float_flag_divbyzero, s); - return float32_set_sign(float32_infinity, float32_is_neg(f32)); - } else if (float32_is_neg(f32)) { - float_raise(float_flag_invalid, s); - return float32_default_nan(s); - } else if (float32_is_infinity(f32)) { - return float32_zero; - } - - /* Scale and normalize to a double-precision value between 0.25 and 1.0, - * preserving the parity of the exponent. */ - - f64_frac = ((uint64_t) f32_frac) << 29; - - f64_frac = recip_sqrt_estimate(&f32_exp, 380, f64_frac); - - /* result = sign : result_exp<4:0> : estimate<7:0> : Zeros(15) */ - val = deposit32(0, 31, 1, f32_sign); - val = deposit32(val, 23, 8, f32_exp); - val = deposit32(val, 15, 8, extract64(f64_frac, 52 - 8, 8)); - return make_float32(val); -} - -float64 HELPER(rsqrte_f64)(float64 input, void *fpstp) -{ - float_status *s = fpstp; - float64 f64 = float64_squash_input_denormal(input, s); - uint64_t val = float64_val(f64); - bool f64_sign = float64_is_neg(f64); - int f64_exp = extract64(val, 52, 11); - uint64_t f64_frac = extract64(val, 0, 52); - - if (float64_is_any_nan(f64)) { - float64 nan = f64; - if (float64_is_signaling_nan(f64, s)) { - float_raise(float_flag_invalid, s); - nan = float64_silence_nan(f64, s); - } - if (s->default_nan_mode) { - nan = float64_default_nan(s); - } - return nan; - } else if (float64_is_zero(f64)) { - float_raise(float_flag_divbyzero, s); - return float64_set_sign(float64_infinity, float64_is_neg(f64)); - } else if (float64_is_neg(f64)) { - float_raise(float_flag_invalid, s); - return float64_default_nan(s); - } else if (float64_is_infinity(f64)) { - return float64_zero; - } - - f64_frac = recip_sqrt_estimate(&f64_exp, 3068, f64_frac); - - /* result = sign : result_exp<4:0> : estimate<7:0> : Zeros(44) */ - val = deposit64(0, 61, 1, f64_sign); - val = deposit64(val, 52, 11, f64_exp); - val = deposit64(val, 44, 8, extract64(f64_frac, 52 - 8, 8)); - return make_float64(val); -} - -uint32_t HELPER(recpe_u32)(uint32_t a, void *fpstp) -{ - /* float_status *s = fpstp; */ - int input, estimate; - - if ((a & 0x80000000) == 0) { - return 0xffffffff; - } - - input = extract32(a, 23, 9); - estimate = recip_estimate(input); - - return deposit32(0, (32 - 9), 9, estimate); -} - -uint32_t HELPER(rsqrte_u32)(uint32_t a, void *fpstp) -{ - int estimate; - - if ((a & 0xc0000000) == 0) { - return 0xffffffff; - } - - estimate = do_recip_sqrt_estimate(extract32(a, 23, 9)); - - return deposit32(0, 23, 9, estimate); -} - -/* VFPv4 fused multiply-accumulate */ -float32 VFP_HELPER(muladd, s)(float32 a, float32 b, float32 c, void *fpstp) -{ - float_status *fpst = fpstp; - return float32_muladd(a, b, c, 0, fpst); -} - -float64 VFP_HELPER(muladd, d)(float64 a, float64 b, float64 c, void *fpstp) -{ - float_status *fpst = fpstp; - return float64_muladd(a, b, c, 0, fpst); -} - -/* ARMv8 round to integral */ -float32 HELPER(rints_exact)(float32 x, void *fp_status) -{ - return float32_round_to_int(x, fp_status); -} - -float64 HELPER(rintd_exact)(float64 x, void *fp_status) -{ - return float64_round_to_int(x, fp_status); -} - -float32 HELPER(rints)(float32 x, void *fp_status) -{ - int old_flags = get_float_exception_flags(fp_status), new_flags; - float32 ret; - - ret = float32_round_to_int(x, fp_status); - - /* Suppress any inexact exceptions the conversion produced */ - if (!(old_flags & float_flag_inexact)) { - new_flags = get_float_exception_flags(fp_status); - set_float_exception_flags(new_flags & ~float_flag_inexact, fp_status); - } - - return ret; -} - -float64 HELPER(rintd)(float64 x, void *fp_status) -{ - int old_flags = get_float_exception_flags(fp_status), new_flags; - float64 ret; - - ret = float64_round_to_int(x, fp_status); - - new_flags = get_float_exception_flags(fp_status); - - /* Suppress any inexact exceptions the conversion produced */ - if (!(old_flags & float_flag_inexact)) { - new_flags = get_float_exception_flags(fp_status); - set_float_exception_flags(new_flags & ~float_flag_inexact, fp_status); - } - - return ret; -} - -/* Convert ARM rounding mode to softfloat */ -int arm_rmode_to_sf(int rmode) -{ - switch (rmode) { - case FPROUNDING_TIEAWAY: - rmode = float_round_ties_away; - break; - case FPROUNDING_ODD: - /* FIXME: add support for TIEAWAY and ODD */ - qemu_log_mask(LOG_UNIMP, "arm: unimplemented rounding mode: %d\n", - rmode); - /* fall through for now */ - case FPROUNDING_TIEEVEN: - default: - rmode = float_round_nearest_even; - break; - case FPROUNDING_POSINF: - rmode = float_round_up; - break; - case FPROUNDING_NEGINF: - rmode = float_round_down; - break; - case FPROUNDING_ZERO: - rmode = float_round_to_zero; - break; - } - return rmode; -} - /* CRC helpers. * The upper bytes of val (above the number specified by 'bytes') must have * been zeroed out by the caller. diff --git a/target/arm/vfp_helper.c b/target/arm/vfp_helper.c new file mode 100644 index 00000000000..74d3030c471 --- /dev/null +++ b/target/arm/vfp_helper.c @@ -0,0 +1,1088 @@ +/* + * ARM VFP floating-point operations + * + * Copyright (c) 2003 Fabrice Bellard + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + */ + +#include "qemu/osdep.h" +#include "qemu/log.h" +#include "cpu.h" +#include "exec/helper-proto.h" +#include "fpu/softfloat.h" +#include "internals.h" + + +/* VFP support. We follow the convention used for VFP instructions: + Single precision routines have a "s" suffix, double precision a + "d" suffix. */ + +/* Convert host exception flags to vfp form. */ +static inline int vfp_exceptbits_from_host(int host_bits) +{ + int target_bits = 0; + + if (host_bits & float_flag_invalid) + target_bits |= 1; + if (host_bits & float_flag_divbyzero) + target_bits |= 2; + if (host_bits & float_flag_overflow) + target_bits |= 4; + if (host_bits & (float_flag_underflow | float_flag_output_denormal)) + target_bits |= 8; + if (host_bits & float_flag_inexact) + target_bits |= 0x10; + if (host_bits & float_flag_input_denormal) + target_bits |= 0x80; + return target_bits; +} + +uint32_t HELPER(vfp_get_fpscr)(CPUARMState *env) +{ + uint32_t i, fpscr; + + fpscr = env->vfp.xregs[ARM_VFP_FPSCR] + | (env->vfp.vec_len << 16) + | (env->vfp.vec_stride << 20); + + i = get_float_exception_flags(&env->vfp.fp_status); + i |= get_float_exception_flags(&env->vfp.standard_fp_status); + /* FZ16 does not generate an input denormal exception. */ + i |= (get_float_exception_flags(&env->vfp.fp_status_f16) + & ~float_flag_input_denormal); + fpscr |= vfp_exceptbits_from_host(i); + + i = env->vfp.qc[0] | env->vfp.qc[1] | env->vfp.qc[2] | env->vfp.qc[3]; + fpscr |= i ? FPCR_QC : 0; + + return fpscr; +} + +uint32_t vfp_get_fpscr(CPUARMState *env) +{ + return HELPER(vfp_get_fpscr)(env); +} + +/* Convert vfp exception flags to target form. */ +static inline int vfp_exceptbits_to_host(int target_bits) +{ + int host_bits = 0; + + if (target_bits & 1) + host_bits |= float_flag_invalid; + if (target_bits & 2) + host_bits |= float_flag_divbyzero; + if (target_bits & 4) + host_bits |= float_flag_overflow; + if (target_bits & 8) + host_bits |= float_flag_underflow; + if (target_bits & 0x10) + host_bits |= float_flag_inexact; + if (target_bits & 0x80) + host_bits |= float_flag_input_denormal; + return host_bits; +} + +void HELPER(vfp_set_fpscr)(CPUARMState *env, uint32_t val) +{ + int i; + uint32_t changed = env->vfp.xregs[ARM_VFP_FPSCR]; + + /* When ARMv8.2-FP16 is not supported, FZ16 is RES0. */ + if (!cpu_isar_feature(aa64_fp16, arm_env_get_cpu(env))) { + val &= ~FPCR_FZ16; + } + + /* + * We don't implement trapped exception handling, so the + * trap enable bits, IDE|IXE|UFE|OFE|DZE|IOE are all RAZ/WI (not RES0!) + * + * If we exclude the exception flags, IOC|DZC|OFC|UFC|IXC|IDC + * (which are stored in fp_status), and the other RES0 bits + * in between, then we clear all of the low 16 bits. + */ + env->vfp.xregs[ARM_VFP_FPSCR] = val & 0xf7c80000; + env->vfp.vec_len = (val >> 16) & 7; + env->vfp.vec_stride = (val >> 20) & 3; + + /* + * The bit we set within fpscr_q is arbitrary; the register as a + * whole being zero/non-zero is what counts. + */ + env->vfp.qc[0] = val & FPCR_QC; + env->vfp.qc[1] = 0; + env->vfp.qc[2] = 0; + env->vfp.qc[3] = 0; + + changed ^= val; + if (changed & (3 << 22)) { + i = (val >> 22) & 3; + switch (i) { + case FPROUNDING_TIEEVEN: + i = float_round_nearest_even; + break; + case FPROUNDING_POSINF: + i = float_round_up; + break; + case FPROUNDING_NEGINF: + i = float_round_down; + break; + case FPROUNDING_ZERO: + i = float_round_to_zero; + break; + } + set_float_rounding_mode(i, &env->vfp.fp_status); + set_float_rounding_mode(i, &env->vfp.fp_status_f16); + } + if (changed & FPCR_FZ16) { + bool ftz_enabled = val & FPCR_FZ16; + set_flush_to_zero(ftz_enabled, &env->vfp.fp_status_f16); + set_flush_inputs_to_zero(ftz_enabled, &env->vfp.fp_status_f16); + } + if (changed & FPCR_FZ) { + bool ftz_enabled = val & FPCR_FZ; + set_flush_to_zero(ftz_enabled, &env->vfp.fp_status); + set_flush_inputs_to_zero(ftz_enabled, &env->vfp.fp_status); + } + if (changed & FPCR_DN) { + bool dnan_enabled = val & FPCR_DN; + set_default_nan_mode(dnan_enabled, &env->vfp.fp_status); + set_default_nan_mode(dnan_enabled, &env->vfp.fp_status_f16); + } + + /* The exception flags are ORed together when we read fpscr so we + * only need to preserve the current state in one of our + * float_status values. + */ + i = vfp_exceptbits_to_host(val); + set_float_exception_flags(i, &env->vfp.fp_status); + set_float_exception_flags(0, &env->vfp.fp_status_f16); + set_float_exception_flags(0, &env->vfp.standard_fp_status); +} + +void vfp_set_fpscr(CPUARMState *env, uint32_t val) +{ + HELPER(vfp_set_fpscr)(env, val); +} + +#define VFP_HELPER(name, p) HELPER(glue(glue(vfp_,name),p)) + +#define VFP_BINOP(name) \ +float32 VFP_HELPER(name, s)(float32 a, float32 b, void *fpstp) \ +{ \ + float_status *fpst = fpstp; \ + return float32_ ## name(a, b, fpst); \ +} \ +float64 VFP_HELPER(name, d)(float64 a, float64 b, void *fpstp) \ +{ \ + float_status *fpst = fpstp; \ + return float64_ ## name(a, b, fpst); \ +} +VFP_BINOP(add) +VFP_BINOP(sub) +VFP_BINOP(mul) +VFP_BINOP(div) +VFP_BINOP(min) +VFP_BINOP(max) +VFP_BINOP(minnum) +VFP_BINOP(maxnum) +#undef VFP_BINOP + +float32 VFP_HELPER(neg, s)(float32 a) +{ + return float32_chs(a); +} + +float64 VFP_HELPER(neg, d)(float64 a) +{ + return float64_chs(a); +} + +float32 VFP_HELPER(abs, s)(float32 a) +{ + return float32_abs(a); +} + +float64 VFP_HELPER(abs, d)(float64 a) +{ + return float64_abs(a); +} + +float32 VFP_HELPER(sqrt, s)(float32 a, CPUARMState *env) +{ + return float32_sqrt(a, &env->vfp.fp_status); +} + +float64 VFP_HELPER(sqrt, d)(float64 a, CPUARMState *env) +{ + return float64_sqrt(a, &env->vfp.fp_status); +} + +static void softfloat_to_vfp_compare(CPUARMState *env, int cmp) +{ + uint32_t flags; + switch (cmp) { + case float_relation_equal: + flags = 0x6; + break; + case float_relation_less: + flags = 0x8; + break; + case float_relation_greater: + flags = 0x2; + break; + case float_relation_unordered: + flags = 0x3; + break; + default: + g_assert_not_reached(); + } + env->vfp.xregs[ARM_VFP_FPSCR] = + deposit32(env->vfp.xregs[ARM_VFP_FPSCR], 28, 4, flags); +} + +/* XXX: check quiet/signaling case */ +#define DO_VFP_cmp(p, type) \ +void VFP_HELPER(cmp, p)(type a, type b, CPUARMState *env) \ +{ \ + softfloat_to_vfp_compare(env, \ + type ## _compare_quiet(a, b, &env->vfp.fp_status)); \ +} \ +void VFP_HELPER(cmpe, p)(type a, type b, CPUARMState *env) \ +{ \ + softfloat_to_vfp_compare(env, \ + type ## _compare(a, b, &env->vfp.fp_status)); \ +} +DO_VFP_cmp(s, float32) +DO_VFP_cmp(d, float64) +#undef DO_VFP_cmp + +/* Integer to float and float to integer conversions */ + +#define CONV_ITOF(name, ftype, fsz, sign) \ +ftype HELPER(name)(uint32_t x, void *fpstp) \ +{ \ + float_status *fpst = fpstp; \ + return sign##int32_to_##float##fsz((sign##int32_t)x, fpst); \ +} + +#define CONV_FTOI(name, ftype, fsz, sign, round) \ +sign##int32_t HELPER(name)(ftype x, void *fpstp) \ +{ \ + float_status *fpst = fpstp; \ + if (float##fsz##_is_any_nan(x)) { \ + float_raise(float_flag_invalid, fpst); \ + return 0; \ + } \ + return float##fsz##_to_##sign##int32##round(x, fpst); \ +} + +#define FLOAT_CONVS(name, p, ftype, fsz, sign) \ + CONV_ITOF(vfp_##name##to##p, ftype, fsz, sign) \ + CONV_FTOI(vfp_to##name##p, ftype, fsz, sign, ) \ + CONV_FTOI(vfp_to##name##z##p, ftype, fsz, sign, _round_to_zero) + +FLOAT_CONVS(si, h, uint32_t, 16, ) +FLOAT_CONVS(si, s, float32, 32, ) +FLOAT_CONVS(si, d, float64, 64, ) +FLOAT_CONVS(ui, h, uint32_t, 16, u) +FLOAT_CONVS(ui, s, float32, 32, u) +FLOAT_CONVS(ui, d, float64, 64, u) + +#undef CONV_ITOF +#undef CONV_FTOI +#undef FLOAT_CONVS + +/* floating point conversion */ +float64 VFP_HELPER(fcvtd, s)(float32 x, CPUARMState *env) +{ + return float32_to_float64(x, &env->vfp.fp_status); +} + +float32 VFP_HELPER(fcvts, d)(float64 x, CPUARMState *env) +{ + return float64_to_float32(x, &env->vfp.fp_status); +} + +/* VFP3 fixed point conversion. */ +#define VFP_CONV_FIX_FLOAT(name, p, fsz, isz, itype) \ +float##fsz HELPER(vfp_##name##to##p)(uint##isz##_t x, uint32_t shift, \ + void *fpstp) \ +{ return itype##_to_##float##fsz##_scalbn(x, -shift, fpstp); } + +#define VFP_CONV_FLOAT_FIX_ROUND(name, p, fsz, isz, itype, ROUND, suff) \ +uint##isz##_t HELPER(vfp_to##name##p##suff)(float##fsz x, uint32_t shift, \ + void *fpst) \ +{ \ + if (unlikely(float##fsz##_is_any_nan(x))) { \ + float_raise(float_flag_invalid, fpst); \ + return 0; \ + } \ + return float##fsz##_to_##itype##_scalbn(x, ROUND, shift, fpst); \ +} + +#define VFP_CONV_FIX(name, p, fsz, isz, itype) \ +VFP_CONV_FIX_FLOAT(name, p, fsz, isz, itype) \ +VFP_CONV_FLOAT_FIX_ROUND(name, p, fsz, isz, itype, \ + float_round_to_zero, _round_to_zero) \ +VFP_CONV_FLOAT_FIX_ROUND(name, p, fsz, isz, itype, \ + get_float_rounding_mode(fpst), ) + +#define VFP_CONV_FIX_A64(name, p, fsz, isz, itype) \ +VFP_CONV_FIX_FLOAT(name, p, fsz, isz, itype) \ +VFP_CONV_FLOAT_FIX_ROUND(name, p, fsz, isz, itype, \ + get_float_rounding_mode(fpst), ) + +VFP_CONV_FIX(sh, d, 64, 64, int16) +VFP_CONV_FIX(sl, d, 64, 64, int32) +VFP_CONV_FIX_A64(sq, d, 64, 64, int64) +VFP_CONV_FIX(uh, d, 64, 64, uint16) +VFP_CONV_FIX(ul, d, 64, 64, uint32) +VFP_CONV_FIX_A64(uq, d, 64, 64, uint64) +VFP_CONV_FIX(sh, s, 32, 32, int16) +VFP_CONV_FIX(sl, s, 32, 32, int32) +VFP_CONV_FIX_A64(sq, s, 32, 64, int64) +VFP_CONV_FIX(uh, s, 32, 32, uint16) +VFP_CONV_FIX(ul, s, 32, 32, uint32) +VFP_CONV_FIX_A64(uq, s, 32, 64, uint64) + +#undef VFP_CONV_FIX +#undef VFP_CONV_FIX_FLOAT +#undef VFP_CONV_FLOAT_FIX_ROUND +#undef VFP_CONV_FIX_A64 + +uint32_t HELPER(vfp_sltoh)(uint32_t x, uint32_t shift, void *fpst) +{ + return int32_to_float16_scalbn(x, -shift, fpst); +} + +uint32_t HELPER(vfp_ultoh)(uint32_t x, uint32_t shift, void *fpst) +{ + return uint32_to_float16_scalbn(x, -shift, fpst); +} + +uint32_t HELPER(vfp_sqtoh)(uint64_t x, uint32_t shift, void *fpst) +{ + return int64_to_float16_scalbn(x, -shift, fpst); +} + +uint32_t HELPER(vfp_uqtoh)(uint64_t x, uint32_t shift, void *fpst) +{ + return uint64_to_float16_scalbn(x, -shift, fpst); +} + +uint32_t HELPER(vfp_toshh)(uint32_t x, uint32_t shift, void *fpst) +{ + if (unlikely(float16_is_any_nan(x))) { + float_raise(float_flag_invalid, fpst); + return 0; + } + return float16_to_int16_scalbn(x, get_float_rounding_mode(fpst), + shift, fpst); +} + +uint32_t HELPER(vfp_touhh)(uint32_t x, uint32_t shift, void *fpst) +{ + if (unlikely(float16_is_any_nan(x))) { + float_raise(float_flag_invalid, fpst); + return 0; + } + return float16_to_uint16_scalbn(x, get_float_rounding_mode(fpst), + shift, fpst); +} + +uint32_t HELPER(vfp_toslh)(uint32_t x, uint32_t shift, void *fpst) +{ + if (unlikely(float16_is_any_nan(x))) { + float_raise(float_flag_invalid, fpst); + return 0; + } + return float16_to_int32_scalbn(x, get_float_rounding_mode(fpst), + shift, fpst); +} + +uint32_t HELPER(vfp_toulh)(uint32_t x, uint32_t shift, void *fpst) +{ + if (unlikely(float16_is_any_nan(x))) { + float_raise(float_flag_invalid, fpst); + return 0; + } + return float16_to_uint32_scalbn(x, get_float_rounding_mode(fpst), + shift, fpst); +} + +uint64_t HELPER(vfp_tosqh)(uint32_t x, uint32_t shift, void *fpst) +{ + if (unlikely(float16_is_any_nan(x))) { + float_raise(float_flag_invalid, fpst); + return 0; + } + return float16_to_int64_scalbn(x, get_float_rounding_mode(fpst), + shift, fpst); +} + +uint64_t HELPER(vfp_touqh)(uint32_t x, uint32_t shift, void *fpst) +{ + if (unlikely(float16_is_any_nan(x))) { + float_raise(float_flag_invalid, fpst); + return 0; + } + return float16_to_uint64_scalbn(x, get_float_rounding_mode(fpst), + shift, fpst); +} + +/* Set the current fp rounding mode and return the old one. + * The argument is a softfloat float_round_ value. + */ +uint32_t HELPER(set_rmode)(uint32_t rmode, void *fpstp) +{ + float_status *fp_status = fpstp; + + uint32_t prev_rmode = get_float_rounding_mode(fp_status); + set_float_rounding_mode(rmode, fp_status); + + return prev_rmode; +} + +/* Set the current fp rounding mode in the standard fp status and return + * the old one. This is for NEON instructions that need to change the + * rounding mode but wish to use the standard FPSCR values for everything + * else. Always set the rounding mode back to the correct value after + * modifying it. + * The argument is a softfloat float_round_ value. + */ +uint32_t HELPER(set_neon_rmode)(uint32_t rmode, CPUARMState *env) +{ + float_status *fp_status = &env->vfp.standard_fp_status; + + uint32_t prev_rmode = get_float_rounding_mode(fp_status); + set_float_rounding_mode(rmode, fp_status); + + return prev_rmode; +} + +/* Half precision conversions. */ +float32 HELPER(vfp_fcvt_f16_to_f32)(uint32_t a, void *fpstp, uint32_t ahp_mode) +{ + /* Squash FZ16 to 0 for the duration of conversion. In this case, + * it would affect flushing input denormals. + */ + float_status *fpst = fpstp; + flag save = get_flush_inputs_to_zero(fpst); + set_flush_inputs_to_zero(false, fpst); + float32 r = float16_to_float32(a, !ahp_mode, fpst); + set_flush_inputs_to_zero(save, fpst); + return r; +} + +uint32_t HELPER(vfp_fcvt_f32_to_f16)(float32 a, void *fpstp, uint32_t ahp_mode) +{ + /* Squash FZ16 to 0 for the duration of conversion. In this case, + * it would affect flushing output denormals. + */ + float_status *fpst = fpstp; + flag save = get_flush_to_zero(fpst); + set_flush_to_zero(false, fpst); + float16 r = float32_to_float16(a, !ahp_mode, fpst); + set_flush_to_zero(save, fpst); + return r; +} + +float64 HELPER(vfp_fcvt_f16_to_f64)(uint32_t a, void *fpstp, uint32_t ahp_mode) +{ + /* Squash FZ16 to 0 for the duration of conversion. In this case, + * it would affect flushing input denormals. + */ + float_status *fpst = fpstp; + flag save = get_flush_inputs_to_zero(fpst); + set_flush_inputs_to_zero(false, fpst); + float64 r = float16_to_float64(a, !ahp_mode, fpst); + set_flush_inputs_to_zero(save, fpst); + return r; +} + +uint32_t HELPER(vfp_fcvt_f64_to_f16)(float64 a, void *fpstp, uint32_t ahp_mode) +{ + /* Squash FZ16 to 0 for the duration of conversion. In this case, + * it would affect flushing output denormals. + */ + float_status *fpst = fpstp; + flag save = get_flush_to_zero(fpst); + set_flush_to_zero(false, fpst); + float16 r = float64_to_float16(a, !ahp_mode, fpst); + set_flush_to_zero(save, fpst); + return r; +} + +#define float32_two make_float32(0x40000000) +#define float32_three make_float32(0x40400000) +#define float32_one_point_five make_float32(0x3fc00000) + +float32 HELPER(recps_f32)(float32 a, float32 b, CPUARMState *env) +{ + float_status *s = &env->vfp.standard_fp_status; + if ((float32_is_infinity(a) && float32_is_zero_or_denormal(b)) || + (float32_is_infinity(b) && float32_is_zero_or_denormal(a))) { + if (!(float32_is_zero(a) || float32_is_zero(b))) { + float_raise(float_flag_input_denormal, s); + } + return float32_two; + } + return float32_sub(float32_two, float32_mul(a, b, s), s); +} + +float32 HELPER(rsqrts_f32)(float32 a, float32 b, CPUARMState *env) +{ + float_status *s = &env->vfp.standard_fp_status; + float32 product; + if ((float32_is_infinity(a) && float32_is_zero_or_denormal(b)) || + (float32_is_infinity(b) && float32_is_zero_or_denormal(a))) { + if (!(float32_is_zero(a) || float32_is_zero(b))) { + float_raise(float_flag_input_denormal, s); + } + return float32_one_point_five; + } + product = float32_mul(a, b, s); + return float32_div(float32_sub(float32_three, product, s), float32_two, s); +} + +/* NEON helpers. */ + +/* Constants 256 and 512 are used in some helpers; we avoid relying on + * int->float conversions at run-time. */ +#define float64_256 make_float64(0x4070000000000000LL) +#define float64_512 make_float64(0x4080000000000000LL) +#define float16_maxnorm make_float16(0x7bff) +#define float32_maxnorm make_float32(0x7f7fffff) +#define float64_maxnorm make_float64(0x7fefffffffffffffLL) + +/* Reciprocal functions + * + * The algorithm that must be used to calculate the estimate + * is specified by the ARM ARM, see FPRecipEstimate()/RecipEstimate + */ + +/* See RecipEstimate() + * + * input is a 9 bit fixed point number + * input range 256 .. 511 for a number from 0.5 <= x < 1.0. + * result range 256 .. 511 for a number from 1.0 to 511/256. + */ + +static int recip_estimate(int input) +{ + int a, b, r; + assert(256 <= input && input < 512); + a = (input * 2) + 1; + b = (1 << 19) / a; + r = (b + 1) >> 1; + assert(256 <= r && r < 512); + return r; +} + +/* + * Common wrapper to call recip_estimate + * + * The parameters are exponent and 64 bit fraction (without implicit + * bit) where the binary point is nominally at bit 52. Returns a + * float64 which can then be rounded to the appropriate size by the + * callee. + */ + +static uint64_t call_recip_estimate(int *exp, int exp_off, uint64_t frac) +{ + uint32_t scaled, estimate; + uint64_t result_frac; + int result_exp; + + /* Handle sub-normals */ + if (*exp == 0) { + if (extract64(frac, 51, 1) == 0) { + *exp = -1; + frac <<= 2; + } else { + frac <<= 1; + } + } + + /* scaled = UInt('1':fraction<51:44>) */ + scaled = deposit32(1 << 8, 0, 8, extract64(frac, 44, 8)); + estimate = recip_estimate(scaled); + + result_exp = exp_off - *exp; + result_frac = deposit64(0, 44, 8, estimate); + if (result_exp == 0) { + result_frac = deposit64(result_frac >> 1, 51, 1, 1); + } else if (result_exp == -1) { + result_frac = deposit64(result_frac >> 2, 50, 2, 1); + result_exp = 0; + } + + *exp = result_exp; + + return result_frac; +} + +static bool round_to_inf(float_status *fpst, bool sign_bit) +{ + switch (fpst->float_rounding_mode) { + case float_round_nearest_even: /* Round to Nearest */ + return true; + case float_round_up: /* Round to +Inf */ + return !sign_bit; + case float_round_down: /* Round to -Inf */ + return sign_bit; + case float_round_to_zero: /* Round to Zero */ + return false; + } + + g_assert_not_reached(); +} + +uint32_t HELPER(recpe_f16)(uint32_t input, void *fpstp) +{ + float_status *fpst = fpstp; + float16 f16 = float16_squash_input_denormal(input, fpst); + uint32_t f16_val = float16_val(f16); + uint32_t f16_sign = float16_is_neg(f16); + int f16_exp = extract32(f16_val, 10, 5); + uint32_t f16_frac = extract32(f16_val, 0, 10); + uint64_t f64_frac; + + if (float16_is_any_nan(f16)) { + float16 nan = f16; + if (float16_is_signaling_nan(f16, fpst)) { + float_raise(float_flag_invalid, fpst); + nan = float16_silence_nan(f16, fpst); + } + if (fpst->default_nan_mode) { + nan = float16_default_nan(fpst); + } + return nan; + } else if (float16_is_infinity(f16)) { + return float16_set_sign(float16_zero, float16_is_neg(f16)); + } else if (float16_is_zero(f16)) { + float_raise(float_flag_divbyzero, fpst); + return float16_set_sign(float16_infinity, float16_is_neg(f16)); + } else if (float16_abs(f16) < (1 << 8)) { + /* Abs(value) < 2.0^-16 */ + float_raise(float_flag_overflow | float_flag_inexact, fpst); + if (round_to_inf(fpst, f16_sign)) { + return float16_set_sign(float16_infinity, f16_sign); + } else { + return float16_set_sign(float16_maxnorm, f16_sign); + } + } else if (f16_exp >= 29 && fpst->flush_to_zero) { + float_raise(float_flag_underflow, fpst); + return float16_set_sign(float16_zero, float16_is_neg(f16)); + } + + f64_frac = call_recip_estimate(&f16_exp, 29, + ((uint64_t) f16_frac) << (52 - 10)); + + /* result = sign : result_exp<4:0> : fraction<51:42> */ + f16_val = deposit32(0, 15, 1, f16_sign); + f16_val = deposit32(f16_val, 10, 5, f16_exp); + f16_val = deposit32(f16_val, 0, 10, extract64(f64_frac, 52 - 10, 10)); + return make_float16(f16_val); +} + +float32 HELPER(recpe_f32)(float32 input, void *fpstp) +{ + float_status *fpst = fpstp; + float32 f32 = float32_squash_input_denormal(input, fpst); + uint32_t f32_val = float32_val(f32); + bool f32_sign = float32_is_neg(f32); + int f32_exp = extract32(f32_val, 23, 8); + uint32_t f32_frac = extract32(f32_val, 0, 23); + uint64_t f64_frac; + + if (float32_is_any_nan(f32)) { + float32 nan = f32; + if (float32_is_signaling_nan(f32, fpst)) { + float_raise(float_flag_invalid, fpst); + nan = float32_silence_nan(f32, fpst); + } + if (fpst->default_nan_mode) { + nan = float32_default_nan(fpst); + } + return nan; + } else if (float32_is_infinity(f32)) { + return float32_set_sign(float32_zero, float32_is_neg(f32)); + } else if (float32_is_zero(f32)) { + float_raise(float_flag_divbyzero, fpst); + return float32_set_sign(float32_infinity, float32_is_neg(f32)); + } else if (float32_abs(f32) < (1ULL << 21)) { + /* Abs(value) < 2.0^-128 */ + float_raise(float_flag_overflow | float_flag_inexact, fpst); + if (round_to_inf(fpst, f32_sign)) { + return float32_set_sign(float32_infinity, f32_sign); + } else { + return float32_set_sign(float32_maxnorm, f32_sign); + } + } else if (f32_exp >= 253 && fpst->flush_to_zero) { + float_raise(float_flag_underflow, fpst); + return float32_set_sign(float32_zero, float32_is_neg(f32)); + } + + f64_frac = call_recip_estimate(&f32_exp, 253, + ((uint64_t) f32_frac) << (52 - 23)); + + /* result = sign : result_exp<7:0> : fraction<51:29> */ + f32_val = deposit32(0, 31, 1, f32_sign); + f32_val = deposit32(f32_val, 23, 8, f32_exp); + f32_val = deposit32(f32_val, 0, 23, extract64(f64_frac, 52 - 23, 23)); + return make_float32(f32_val); +} + +float64 HELPER(recpe_f64)(float64 input, void *fpstp) +{ + float_status *fpst = fpstp; + float64 f64 = float64_squash_input_denormal(input, fpst); + uint64_t f64_val = float64_val(f64); + bool f64_sign = float64_is_neg(f64); + int f64_exp = extract64(f64_val, 52, 11); + uint64_t f64_frac = extract64(f64_val, 0, 52); + + /* Deal with any special cases */ + if (float64_is_any_nan(f64)) { + float64 nan = f64; + if (float64_is_signaling_nan(f64, fpst)) { + float_raise(float_flag_invalid, fpst); + nan = float64_silence_nan(f64, fpst); + } + if (fpst->default_nan_mode) { + nan = float64_default_nan(fpst); + } + return nan; + } else if (float64_is_infinity(f64)) { + return float64_set_sign(float64_zero, float64_is_neg(f64)); + } else if (float64_is_zero(f64)) { + float_raise(float_flag_divbyzero, fpst); + return float64_set_sign(float64_infinity, float64_is_neg(f64)); + } else if ((f64_val & ~(1ULL << 63)) < (1ULL << 50)) { + /* Abs(value) < 2.0^-1024 */ + float_raise(float_flag_overflow | float_flag_inexact, fpst); + if (round_to_inf(fpst, f64_sign)) { + return float64_set_sign(float64_infinity, f64_sign); + } else { + return float64_set_sign(float64_maxnorm, f64_sign); + } + } else if (f64_exp >= 2045 && fpst->flush_to_zero) { + float_raise(float_flag_underflow, fpst); + return float64_set_sign(float64_zero, float64_is_neg(f64)); + } + + f64_frac = call_recip_estimate(&f64_exp, 2045, f64_frac); + + /* result = sign : result_exp<10:0> : fraction<51:0>; */ + f64_val = deposit64(0, 63, 1, f64_sign); + f64_val = deposit64(f64_val, 52, 11, f64_exp); + f64_val = deposit64(f64_val, 0, 52, f64_frac); + return make_float64(f64_val); +} + +/* The algorithm that must be used to calculate the estimate + * is specified by the ARM ARM. + */ + +static int do_recip_sqrt_estimate(int a) +{ + int b, estimate; + + assert(128 <= a && a < 512); + if (a < 256) { + a = a * 2 + 1; + } else { + a = (a >> 1) << 1; + a = (a + 1) * 2; + } + b = 512; + while (a * (b + 1) * (b + 1) < (1 << 28)) { + b += 1; + } + estimate = (b + 1) / 2; + assert(256 <= estimate && estimate < 512); + + return estimate; +} + + +static uint64_t recip_sqrt_estimate(int *exp , int exp_off, uint64_t frac) +{ + int estimate; + uint32_t scaled; + + if (*exp == 0) { + while (extract64(frac, 51, 1) == 0) { + frac = frac << 1; + *exp -= 1; + } + frac = extract64(frac, 0, 51) << 1; + } + + if (*exp & 1) { + /* scaled = UInt('01':fraction<51:45>) */ + scaled = deposit32(1 << 7, 0, 7, extract64(frac, 45, 7)); + } else { + /* scaled = UInt('1':fraction<51:44>) */ + scaled = deposit32(1 << 8, 0, 8, extract64(frac, 44, 8)); + } + estimate = do_recip_sqrt_estimate(scaled); + + *exp = (exp_off - *exp) / 2; + return extract64(estimate, 0, 8) << 44; +} + +uint32_t HELPER(rsqrte_f16)(uint32_t input, void *fpstp) +{ + float_status *s = fpstp; + float16 f16 = float16_squash_input_denormal(input, s); + uint16_t val = float16_val(f16); + bool f16_sign = float16_is_neg(f16); + int f16_exp = extract32(val, 10, 5); + uint16_t f16_frac = extract32(val, 0, 10); + uint64_t f64_frac; + + if (float16_is_any_nan(f16)) { + float16 nan = f16; + if (float16_is_signaling_nan(f16, s)) { + float_raise(float_flag_invalid, s); + nan = float16_silence_nan(f16, s); + } + if (s->default_nan_mode) { + nan = float16_default_nan(s); + } + return nan; + } else if (float16_is_zero(f16)) { + float_raise(float_flag_divbyzero, s); + return float16_set_sign(float16_infinity, f16_sign); + } else if (f16_sign) { + float_raise(float_flag_invalid, s); + return float16_default_nan(s); + } else if (float16_is_infinity(f16)) { + return float16_zero; + } + + /* Scale and normalize to a double-precision value between 0.25 and 1.0, + * preserving the parity of the exponent. */ + + f64_frac = ((uint64_t) f16_frac) << (52 - 10); + + f64_frac = recip_sqrt_estimate(&f16_exp, 44, f64_frac); + + /* result = sign : result_exp<4:0> : estimate<7:0> : Zeros(2) */ + val = deposit32(0, 15, 1, f16_sign); + val = deposit32(val, 10, 5, f16_exp); + val = deposit32(val, 2, 8, extract64(f64_frac, 52 - 8, 8)); + return make_float16(val); +} + +float32 HELPER(rsqrte_f32)(float32 input, void *fpstp) +{ + float_status *s = fpstp; + float32 f32 = float32_squash_input_denormal(input, s); + uint32_t val = float32_val(f32); + uint32_t f32_sign = float32_is_neg(f32); + int f32_exp = extract32(val, 23, 8); + uint32_t f32_frac = extract32(val, 0, 23); + uint64_t f64_frac; + + if (float32_is_any_nan(f32)) { + float32 nan = f32; + if (float32_is_signaling_nan(f32, s)) { + float_raise(float_flag_invalid, s); + nan = float32_silence_nan(f32, s); + } + if (s->default_nan_mode) { + nan = float32_default_nan(s); + } + return nan; + } else if (float32_is_zero(f32)) { + float_raise(float_flag_divbyzero, s); + return float32_set_sign(float32_infinity, float32_is_neg(f32)); + } else if (float32_is_neg(f32)) { + float_raise(float_flag_invalid, s); + return float32_default_nan(s); + } else if (float32_is_infinity(f32)) { + return float32_zero; + } + + /* Scale and normalize to a double-precision value between 0.25 and 1.0, + * preserving the parity of the exponent. */ + + f64_frac = ((uint64_t) f32_frac) << 29; + + f64_frac = recip_sqrt_estimate(&f32_exp, 380, f64_frac); + + /* result = sign : result_exp<4:0> : estimate<7:0> : Zeros(15) */ + val = deposit32(0, 31, 1, f32_sign); + val = deposit32(val, 23, 8, f32_exp); + val = deposit32(val, 15, 8, extract64(f64_frac, 52 - 8, 8)); + return make_float32(val); +} + +float64 HELPER(rsqrte_f64)(float64 input, void *fpstp) +{ + float_status *s = fpstp; + float64 f64 = float64_squash_input_denormal(input, s); + uint64_t val = float64_val(f64); + bool f64_sign = float64_is_neg(f64); + int f64_exp = extract64(val, 52, 11); + uint64_t f64_frac = extract64(val, 0, 52); + + if (float64_is_any_nan(f64)) { + float64 nan = f64; + if (float64_is_signaling_nan(f64, s)) { + float_raise(float_flag_invalid, s); + nan = float64_silence_nan(f64, s); + } + if (s->default_nan_mode) { + nan = float64_default_nan(s); + } + return nan; + } else if (float64_is_zero(f64)) { + float_raise(float_flag_divbyzero, s); + return float64_set_sign(float64_infinity, float64_is_neg(f64)); + } else if (float64_is_neg(f64)) { + float_raise(float_flag_invalid, s); + return float64_default_nan(s); + } else if (float64_is_infinity(f64)) { + return float64_zero; + } + + f64_frac = recip_sqrt_estimate(&f64_exp, 3068, f64_frac); + + /* result = sign : result_exp<4:0> : estimate<7:0> : Zeros(44) */ + val = deposit64(0, 61, 1, f64_sign); + val = deposit64(val, 52, 11, f64_exp); + val = deposit64(val, 44, 8, extract64(f64_frac, 52 - 8, 8)); + return make_float64(val); +} + +uint32_t HELPER(recpe_u32)(uint32_t a, void *fpstp) +{ + /* float_status *s = fpstp; */ + int input, estimate; + + if ((a & 0x80000000) == 0) { + return 0xffffffff; + } + + input = extract32(a, 23, 9); + estimate = recip_estimate(input); + + return deposit32(0, (32 - 9), 9, estimate); +} + +uint32_t HELPER(rsqrte_u32)(uint32_t a, void *fpstp) +{ + int estimate; + + if ((a & 0xc0000000) == 0) { + return 0xffffffff; + } + + estimate = do_recip_sqrt_estimate(extract32(a, 23, 9)); + + return deposit32(0, 23, 9, estimate); +} + +/* VFPv4 fused multiply-accumulate */ +float32 VFP_HELPER(muladd, s)(float32 a, float32 b, float32 c, void *fpstp) +{ + float_status *fpst = fpstp; + return float32_muladd(a, b, c, 0, fpst); +} + +float64 VFP_HELPER(muladd, d)(float64 a, float64 b, float64 c, void *fpstp) +{ + float_status *fpst = fpstp; + return float64_muladd(a, b, c, 0, fpst); +} + +/* ARMv8 round to integral */ +float32 HELPER(rints_exact)(float32 x, void *fp_status) +{ + return float32_round_to_int(x, fp_status); +} + +float64 HELPER(rintd_exact)(float64 x, void *fp_status) +{ + return float64_round_to_int(x, fp_status); +} + +float32 HELPER(rints)(float32 x, void *fp_status) +{ + int old_flags = get_float_exception_flags(fp_status), new_flags; + float32 ret; + + ret = float32_round_to_int(x, fp_status); + + /* Suppress any inexact exceptions the conversion produced */ + if (!(old_flags & float_flag_inexact)) { + new_flags = get_float_exception_flags(fp_status); + set_float_exception_flags(new_flags & ~float_flag_inexact, fp_status); + } + + return ret; +} + +float64 HELPER(rintd)(float64 x, void *fp_status) +{ + int old_flags = get_float_exception_flags(fp_status), new_flags; + float64 ret; + + ret = float64_round_to_int(x, fp_status); + + new_flags = get_float_exception_flags(fp_status); + + /* Suppress any inexact exceptions the conversion produced */ + if (!(old_flags & float_flag_inexact)) { + new_flags = get_float_exception_flags(fp_status); + set_float_exception_flags(new_flags & ~float_flag_inexact, fp_status); + } + + return ret; +} + +/* Convert ARM rounding mode to softfloat */ +int arm_rmode_to_sf(int rmode) +{ + switch (rmode) { + case FPROUNDING_TIEAWAY: + rmode = float_round_ties_away; + break; + case FPROUNDING_ODD: + /* FIXME: add support for TIEAWAY and ODD */ + qemu_log_mask(LOG_UNIMP, "arm: unimplemented rounding mode: %d\n", + rmode); + /* fall through for now */ + case FPROUNDING_TIEEVEN: + default: + rmode = float_round_nearest_even; + break; + case FPROUNDING_POSINF: + rmode = float_round_up; + break; + case FPROUNDING_NEGINF: + rmode = float_round_down; + break; + case FPROUNDING_ZERO: + rmode = float_round_to_zero; + break; + } + return rmode; +} From patchwork Thu Feb 21 18:57:24 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 158943 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp845221jaa; Thu, 21 Feb 2019 11:10:27 -0800 (PST) X-Google-Smtp-Source: AHgI3IYQXALAOC7knh0eeRR/KSmXLU0pZ40+49SLzUxqWXmSFdBZg73t9biyBcTRpQmrhYQWgCPK X-Received: by 2002:a81:ac4f:: with SMTP id z15mr54175ywj.59.1550776227644; Thu, 21 Feb 2019 11:10:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550776227; cv=none; d=google.com; s=arc-20160816; b=vILI3AmY0Htm6vjHJRipPgAolrA9kqolixRARKe5EG5bqDoKUsWmeiPBFtIyc1706s UrkR0Xresi9Yiz3+gnoKrOCAF4j4s9AfbNLodcJL5pndBv12X0eeSeFaum9mbaIJiLhd j6rXzki1uycQFTJuBfWg6wQobiyD33tgs5coXPEO03L9xjTDX63zTIWfppilECofB1PU 5CwuOaAkDo1SqQuIOhTNAu0dXqPrABF1+q+QdzlQ3fzjHy9AG+AHJNdKgDWF++IplLtm Mh0KmkceQoBC2M6lXoJl1U3a6W4SPgTlB4Vvpkq2VMvsyd0DKkKdaXNweQFK7hfHJwhd tDVQ== 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=3CsNdTiJxLpeHZhvA80SvJ6O1mfkLZ6Sw2B47rZsEE4=; b=P9P2Z9Dpf9n+JRgosFUbe0FSB+VOT7SL6cAnOgW2BzNpf51X8seMmEY0yghq5gauSl JQeYbiGvtebSOFQ2bPGLQ1wqrA116Z5m5tnJzNoImlyf+72lld1wRruLN4wvVxK+Qqu8 Or7CS9GBNwrAfTcY5YrJ8BOWWe2mCNrSbpratotHrE7UtxBPhuf1M/iUqsuqxq8r0oZC W9Q7hDQpzVprdSWbAwtiD2ahUWq6ftyUINz8LLCRmWMu8uxcA1ocRK6KBUgWgdvYuBBN 51uW9714Jvu/z9sKKvYl310jJEvOHOvN6cBUE1P+DvDZw+7/PIuvGj4ScsGoKFHnFABU Jw2w== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=mQ5QzCBV; 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 x130si13703082ywc.459.2019.02.21.11.10.27 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 21 Feb 2019 11:10:27 -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=mQ5QzCBV; 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]:37014 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwtjn-0001jB-1y for patch@linaro.org; Thu, 21 Feb 2019 14:10:27 -0500 Received: from eggs.gnu.org ([209.51.188.92]:52233) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwtXs-00004r-Us for qemu-devel@nongnu.org; Thu, 21 Feb 2019 13:58:11 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gwtXp-0007T7-HO for qemu-devel@nongnu.org; Thu, 21 Feb 2019 13:58:08 -0500 Received: from mail-wr1-x432.google.com ([2a00:1450:4864:20::432]:42059) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gwtXp-0007JN-4U for qemu-devel@nongnu.org; Thu, 21 Feb 2019 13:58:05 -0500 Received: by mail-wr1-x432.google.com with SMTP id r5so18445207wrg.9 for ; Thu, 21 Feb 2019 10:57:52 -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=3CsNdTiJxLpeHZhvA80SvJ6O1mfkLZ6Sw2B47rZsEE4=; b=mQ5QzCBVZIWw04gvq+KwiT0GQijOBZYnjCKpxrn0/x1KoQQsz6b/gZJDCaokw4V8qZ 7bA1hXtwgsBk6Vn3v/LE5ujLSdr9vHeQc/7XESNFwl7dNPfrY4lPJ3CjJmIsxWQzDm/g +WQaRtQFmjBKkyX9js81PvKqm4sxS/tnTDCcPIyDFzYmJSrpU8nUfKe+WpkHjZJugUXs 6uP7IXNyhvY+reFv03iXnp8OUr+p3vUNm1wq3n8P1pSH6o0aI+VWbqst1bZkjIJlFNzs 6QKhgQg2IhY4Vrs0mKzWCWaZAmGXo2OiTReYg+OOTdWA0zhOE4J8mZquyoYcgVLXSH8n Jr2w== 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=3CsNdTiJxLpeHZhvA80SvJ6O1mfkLZ6Sw2B47rZsEE4=; b=GurDXZYuPhchrqdoIYfnpBy5Oqj0ZxQ6/52WnC149voBEWwc2i78rLAVG+OfuXhfgA njCDZKg733JSmK4fTl0iWlDPyiJk99TLQIzoisCGAFXy537GlzOs/vRkIPlUesm3iFn4 MLXjTuP8ovYDyPsqREgvLb0I5+O7uBq7uzkuIMIydbcToNSW4TYALDx4tiDN2cFX6ARx qXizWEj55cIrFmgR+7D91/rl3BpCUb678aIxx9hFWXkAzcTd1bCnMNOhYo8ATPSxpJ/I wWj9bhEQ0dmc7zQTgjqPs0KM0oCVdAawuQKrATqn3krUEzNYiPvyY3dnZtvzADrsrr5t pxMQ== X-Gm-Message-State: AHQUAub1vT3yfNhYePKLGHgK+x/DcBJyc3255zkjlTGBgI3/hZFiFdnV KmeBBSE052k4Shi5EXArXokHaP8jIOE= X-Received: by 2002:adf:9123:: with SMTP id j32mr21557wrj.122.1550775470899; Thu, 21 Feb 2019 10:57:50 -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.57.49 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 21 Feb 2019 10:57:50 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Date: Thu, 21 Feb 2019 18:57:24 +0000 Message-Id: <20190221185739.25362-7-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::432 Subject: [Qemu-devel] [PULL 06/21] target/arm: Rearrange Floating-point data-processing (2 regs) X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson There are lots of special cases within these insns. Split the major argument decode/loading/saving into no_output (compares), rd_is_dp, and rm_is_dp. We still need to special case argument load for compare (rd as input, rm as zero) and vcvt fixed (rd as input+output), but lots of special cases do disappear. Now that we have a full switch at the beginning, hoist the ISA checks from the code generation. Signed-off-by: Richard Henderson Message-id: 20190215192302.27855-4-richard.henderson@linaro.org Reviewed-by: Peter Maydell Signed-off-by: Peter Maydell --- target/arm/translate.c | 227 ++++++++++++++++++++--------------------- 1 file changed, 111 insertions(+), 116 deletions(-) -- 2.20.1 diff --git a/target/arm/translate.c b/target/arm/translate.c index dac737f6cac..64c5fe0df3e 100644 --- a/target/arm/translate.c +++ b/target/arm/translate.c @@ -3639,52 +3639,108 @@ static int disas_vfp_insn(DisasContext *s, uint32_t insn) } } else { /* data processing */ + bool rd_is_dp = dp; + bool rm_is_dp = dp; + bool no_output = false; + /* The opcode is in bits 23, 21, 20 and 6. */ op = ((insn >> 20) & 8) | ((insn >> 19) & 6) | ((insn >> 6) & 1); - if (dp) { - if (op == 15) { - /* rn is opcode */ - rn = ((insn >> 15) & 0x1e) | ((insn >> 7) & 1); - } else { - /* rn is register number */ - VFP_DREG_N(rn, insn); - } + rn = VFP_SREG_N(insn); - if (op == 15 && (rn == 15 || ((rn & 0x1c) == 0x18) || - ((rn & 0x1e) == 0x6))) { - /* Integer or single/half precision destination. */ - rd = VFP_SREG_D(insn); - } else { - VFP_DREG_D(rd, insn); - } - if (op == 15 && - (((rn & 0x1c) == 0x10) || ((rn & 0x14) == 0x14) || - ((rn & 0x1e) == 0x4))) { - /* VCVT from int or half precision is always from S reg - * regardless of dp bit. VCVT with immediate frac_bits - * has same format as SREG_M. + if (op == 15) { + /* rn is opcode, encoded as per VFP_SREG_N. */ + switch (rn) { + case 0x00: /* vmov */ + case 0x01: /* vabs */ + case 0x02: /* vneg */ + case 0x03: /* vsqrt */ + break; + + case 0x04: /* vcvtb.f64.f16, vcvtb.f32.f16 */ + case 0x05: /* vcvtt.f64.f16, vcvtt.f32.f16 */ + /* + * VCVTB, VCVTT: only present with the halfprec extension + * UNPREDICTABLE if bit 8 is set prior to ARMv8 + * (we choose to UNDEF) */ - rm = VFP_SREG_M(insn); - } else { - VFP_DREG_M(rm, insn); + if ((dp && !arm_dc_feature(s, ARM_FEATURE_V8)) || + !arm_dc_feature(s, ARM_FEATURE_VFP_FP16)) { + return 1; + } + rm_is_dp = false; + break; + case 0x06: /* vcvtb.f16.f32, vcvtb.f16.f64 */ + case 0x07: /* vcvtt.f16.f32, vcvtt.f16.f64 */ + if ((dp && !arm_dc_feature(s, ARM_FEATURE_V8)) || + !arm_dc_feature(s, ARM_FEATURE_VFP_FP16)) { + return 1; + } + rd_is_dp = false; + break; + + case 0x08: case 0x0a: /* vcmp, vcmpz */ + case 0x09: case 0x0b: /* vcmpe, vcmpez */ + no_output = true; + break; + + case 0x0c: /* vrintr */ + case 0x0d: /* vrintz */ + case 0x0e: /* vrintx */ + break; + + case 0x0f: /* vcvt double<->single */ + rd_is_dp = !dp; + break; + + case 0x10: /* vcvt.fxx.u32 */ + case 0x11: /* vcvt.fxx.s32 */ + rm_is_dp = false; + break; + case 0x18: /* vcvtr.u32.fxx */ + case 0x19: /* vcvtz.u32.fxx */ + case 0x1a: /* vcvtr.s32.fxx */ + case 0x1b: /* vcvtz.s32.fxx */ + rd_is_dp = false; + break; + + case 0x14: /* vcvt fp <-> fixed */ + case 0x15: + case 0x16: + case 0x17: + case 0x1c: + case 0x1d: + case 0x1e: + case 0x1f: + if (!arm_dc_feature(s, ARM_FEATURE_VFP3)) { + return 1; + } + /* Immediate frac_bits has same format as SREG_M. */ + rm_is_dp = false; + break; + + default: + return 1; } + } else if (dp) { + /* rn is register number */ + VFP_DREG_N(rn, insn); + } + + if (rd_is_dp) { + VFP_DREG_D(rd, insn); + } else { + rd = VFP_SREG_D(insn); + } + if (rm_is_dp) { + VFP_DREG_M(rm, insn); } else { - rn = VFP_SREG_N(insn); - if (op == 15 && rn == 15) { - /* Double precision destination. */ - VFP_DREG_D(rd, insn); - } else { - rd = VFP_SREG_D(insn); - } - /* NB that we implicitly rely on the encoding for the frac_bits - * in VCVT of fixed to float being the same as that of an SREG_M - */ rm = VFP_SREG_M(insn); } veclen = s->vec_len; - if (op == 15 && rn > 3) + if (op == 15 && rn > 3) { veclen = 0; + } /* Shut up compiler warnings. */ delta_m = 0; @@ -3720,55 +3776,28 @@ static int disas_vfp_insn(DisasContext *s, uint32_t insn) /* Load the initial operands. */ if (op == 15) { switch (rn) { - case 16: - case 17: - /* Integer source */ - gen_mov_F0_vreg(0, rm); - break; - case 8: - case 9: - /* Compare */ + case 0x08: case 0x09: /* Compare */ gen_mov_F0_vreg(dp, rd); gen_mov_F1_vreg(dp, rm); break; - case 10: - case 11: - /* Compare with zero */ + case 0x0a: case 0x0b: /* Compare with zero */ gen_mov_F0_vreg(dp, rd); gen_vfp_F1_ld0(dp); break; - case 20: - case 21: - case 22: - case 23: - case 28: - case 29: - case 30: - case 31: + case 0x14: /* vcvt fp <-> fixed */ + case 0x15: + case 0x16: + case 0x17: + case 0x1c: + case 0x1d: + case 0x1e: + case 0x1f: /* Source and destination the same. */ gen_mov_F0_vreg(dp, rd); break; - case 4: - case 5: - case 6: - case 7: - /* VCVTB, VCVTT: only present with the halfprec extension - * UNPREDICTABLE if bit 8 is set prior to ARMv8 - * (we choose to UNDEF) - */ - if ((dp && !arm_dc_feature(s, ARM_FEATURE_V8)) || - !arm_dc_feature(s, ARM_FEATURE_VFP_FP16)) { - return 1; - } - if (!extract32(rn, 1, 1)) { - /* Half precision source. */ - gen_mov_F0_vreg(0, rm); - break; - } - /* Otherwise fall through */ default: /* One source operand. */ - gen_mov_F0_vreg(dp, rm); + gen_mov_F0_vreg(rm_is_dp, rm); break; } } else { @@ -4047,10 +4076,11 @@ static int disas_vfp_insn(DisasContext *s, uint32_t insn) break; } case 15: /* single<->double conversion */ - if (dp) + if (dp) { gen_helper_vfp_fcvtsd(cpu_F0s, cpu_F0d, cpu_env); - else + } else { gen_helper_vfp_fcvtds(cpu_F0d, cpu_F0s, cpu_env); + } break; case 16: /* fuito */ gen_vfp_uito(dp, 0); @@ -4059,27 +4089,15 @@ static int disas_vfp_insn(DisasContext *s, uint32_t insn) gen_vfp_sito(dp, 0); break; case 20: /* fshto */ - if (!arm_dc_feature(s, ARM_FEATURE_VFP3)) { - return 1; - } gen_vfp_shto(dp, 16 - rm, 0); break; case 21: /* fslto */ - if (!arm_dc_feature(s, ARM_FEATURE_VFP3)) { - return 1; - } gen_vfp_slto(dp, 32 - rm, 0); break; case 22: /* fuhto */ - if (!arm_dc_feature(s, ARM_FEATURE_VFP3)) { - return 1; - } gen_vfp_uhto(dp, 16 - rm, 0); break; case 23: /* fulto */ - if (!arm_dc_feature(s, ARM_FEATURE_VFP3)) { - return 1; - } gen_vfp_ulto(dp, 32 - rm, 0); break; case 24: /* ftoui */ @@ -4095,57 +4113,34 @@ static int disas_vfp_insn(DisasContext *s, uint32_t insn) gen_vfp_tosiz(dp, 0); break; case 28: /* ftosh */ - if (!arm_dc_feature(s, ARM_FEATURE_VFP3)) { - return 1; - } gen_vfp_tosh(dp, 16 - rm, 0); break; case 29: /* ftosl */ - if (!arm_dc_feature(s, ARM_FEATURE_VFP3)) { - return 1; - } gen_vfp_tosl(dp, 32 - rm, 0); break; case 30: /* ftouh */ - if (!arm_dc_feature(s, ARM_FEATURE_VFP3)) { - return 1; - } gen_vfp_touh(dp, 16 - rm, 0); break; case 31: /* ftoul */ - if (!arm_dc_feature(s, ARM_FEATURE_VFP3)) { - return 1; - } gen_vfp_toul(dp, 32 - rm, 0); break; default: /* undefined */ - return 1; + g_assert_not_reached(); } break; default: /* undefined */ return 1; } - /* Write back the result. */ - if (op == 15 && (rn >= 8 && rn <= 11)) { - /* Comparison, do nothing. */ - } else if (op == 15 && dp && ((rn & 0x1c) == 0x18 || - (rn & 0x1e) == 0x6)) { - /* VCVT double to int: always integer result. - * VCVT double to half precision is always a single - * precision result. - */ - gen_mov_vreg_F0(0, rd); - } else if (op == 15 && rn == 15) { - /* conversion */ - gen_mov_vreg_F0(!dp, rd); - } else { - gen_mov_vreg_F0(dp, rd); + /* Write back the result, if any. */ + if (!no_output) { + gen_mov_vreg_F0(rd_is_dp, rd); } /* break out of the loop if we have finished */ - if (veclen == 0) + if (veclen == 0) { break; + } if (op == 15 && delta_m == 0) { /* single source one-many */ From patchwork Thu Feb 21 18:57:25 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 158952 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp854186jaa; Thu, 21 Feb 2019 11:19:20 -0800 (PST) X-Google-Smtp-Source: AHgI3IZWg6BSuJOcuPHaXVxtWNdw8T+38duiSEwLXKneFHQUMpzHKGf3+TNjyQ9miqbKQTehhsKK X-Received: by 2002:a81:5987:: with SMTP id n129mr83349ywb.95.1550776760471; Thu, 21 Feb 2019 11:19:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550776760; cv=none; d=google.com; s=arc-20160816; b=V6FDo/tWJeexSmWSl4vTeF+PzWnAKdHcPlSA8LsMVuF/PLiTsn0H1YaEeKvVsgvM69 DqzljbsEpNjnIl7Lh3c/kU5hFLGa0zUqH0+91v2/1Hno1fyA38kTIDLGAXYFBbCPGtNX naVjNHdGb40yCRbpp6d9ezUwpGRRPDs3T0NF5hVZ1wjhkjdMq8ZkMmB8pEpjMvSsIRry cGRx5cE8mXE6y/jjpLwaXnA/DanquxyCFkKPYkzlgJwVUKSe2DMefBdcFkGL6wYNHzfM BCtywmbjEHXFvI/zoHuPBQEc0s2oTFW6iNsifeDWndciEjEptXO0NFd1lxzMkUuInblv rXjw== 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=avyth0q/zEQbyaOJ3+FUe4boiwZ15wchLHttHC1gmFU=; b=a1mYH7X5Mw5lANr0vERKr/2a+CMZwi1cOt6WmO3jIuwZbKArAryzVqYXFT51pNVarv 4zVq+kYBdcitlVbM9pirrUD8dQ4ilcnw7Y27LPnJLueoC8+ftLQK3n4doWLT7+TZE7SE wHsn6pAcDb+iebkdQ91QuxxVRlyzwS/zWJhaclzAn0UpvmZ/YjR6OdsMUViozrcnKMn0 CSKYrTOni6nl9z+LNpJ27YHk2t6rsVfnenTOSdthVUfqZMqVR4kkmx4tZX2oIk18ecBI wuycmGfwT01uB4LQH9drCM9sJUJXriZZz9/NJACU56LMu9cWcs4lCUWoqTchNkS6TLcm 46gw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=wahru6PM; 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 a13si12553609ybe.315.2019.02.21.11.19.20 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 21 Feb 2019 11:19:20 -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=wahru6PM; 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]:37161 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwtsN-0000kR-TV for patch@linaro.org; Thu, 21 Feb 2019 14:19:19 -0500 Received: from eggs.gnu.org ([209.51.188.92]:52180) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwtXr-0008Ue-4v for qemu-devel@nongnu.org; Thu, 21 Feb 2019 13:58:10 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gwtXo-0007S7-Uc for qemu-devel@nongnu.org; Thu, 21 Feb 2019 13:58:07 -0500 Received: from mail-wr1-x432.google.com ([2a00:1450:4864:20::432]:36024) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gwtXn-0007Kt-20 for qemu-devel@nongnu.org; Thu, 21 Feb 2019 13:58:03 -0500 Received: by mail-wr1-x432.google.com with SMTP id o17so31822916wrw.3 for ; Thu, 21 Feb 2019 10:57:53 -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=avyth0q/zEQbyaOJ3+FUe4boiwZ15wchLHttHC1gmFU=; b=wahru6PMYIYf/igPecCEuFmsaDhX8H2+bpQ/eL1ngQRHL5Uhyco0tgLPiv8tEe3/c3 8ZSOPrUJaRTtQrOp0IynOjvoUjtfQD9RmZ86UWaBAThbndyrJEAE473E3/2pLvScDAHb ODYUTO4HX5PFv/2qF3t5U33k7H2m1qXXSuwoPgIhbj2luzBiZMLsFPNvRZZFYktSQwq1 bNjcn00/nxpGZJ/SMkfFCCkwy68DYHQHPS4jNR5MSQ2RLJ4XFqUVIvVSyC/DBW/jBKNd pKm/7FVi2TIkfRB/zsCLBa1oLZBhcNLHer28JZ26JE/RzqHUmzME/ckJd2iO4JkTtwMN zPkw== 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=avyth0q/zEQbyaOJ3+FUe4boiwZ15wchLHttHC1gmFU=; b=LnsdOXUgFTi9PR4wmyUNoNVxZw99LX94c+PhUsNL9LyrMWWA/P4TggOepq7EX5/p+j jseOY/9QhpCBGvTIDQ/AEbZLwKpEuB92V4S7JrEFxUhgSGglsPsAxgIFHOwfd0psPWF4 y+8+BeB5jYmd1gwVUXV88ejoZvzO7hiY0RUjJHPjJz1jLIlmr07P2gRASKR1Zx8J3snp 6NgAOrqhoV5d5l5LBP/SHNnfvTyqmZ330HOnc/bObKZ02SVgihWK6Kc2tyMAwZ/1hxZA Q5oSCYWwkL6kT1UGJWkXSPZU9o8qBzcPzmuAS5F2kZoevoMsXTVyhfpnUrAjRVx3BZ43 ryXw== X-Gm-Message-State: AHQUAuYg3QdU1tJoJqZahzjqpXLcklr9QTrWVfvk5OFXKDcDQeK+z1Kn ph5VdUz98sA6rXBcBbs3rbqCWKGc2Dw= X-Received: by 2002:adf:ec41:: with SMTP id w1mr15596wrn.184.1550775472160; Thu, 21 Feb 2019 10:57:52 -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.57.50 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 21 Feb 2019 10:57:51 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Date: Thu, 21 Feb 2019 18:57:25 +0000 Message-Id: <20190221185739.25362-8-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::432 Subject: [Qemu-devel] [PULL 07/21] target/arm: Implement ARMv8.3-JSConv X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson Signed-off-by: Richard Henderson Message-id: 20190215192302.27855-5-richard.henderson@linaro.org Reviewed-by: Peter Maydell [PMM: fixed a couple of comment typos] Signed-off-by: Peter Maydell --- target/arm/cpu.h | 10 +++++ target/arm/helper.h | 3 ++ target/arm/cpu.c | 1 + target/arm/cpu64.c | 2 + target/arm/translate-a64.c | 26 +++++++++++ target/arm/translate.c | 10 +++++ target/arm/vfp_helper.c | 88 ++++++++++++++++++++++++++++++++++++++ 7 files changed, 140 insertions(+) -- 2.20.1 diff --git a/target/arm/cpu.h b/target/arm/cpu.h index 84ae6849c2f..1eea1a408b8 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -3273,6 +3273,11 @@ static inline bool isar_feature_aa32_vcma(const ARMISARegisters *id) return FIELD_EX32(id->id_isar5, ID_ISAR5, VCMA) != 0; } +static inline bool isar_feature_aa32_jscvt(const ARMISARegisters *id) +{ + return FIELD_EX32(id->id_isar6, ID_ISAR6, JSCVT) != 0; +} + static inline bool isar_feature_aa32_dp(const ARMISARegisters *id) { return FIELD_EX32(id->id_isar6, ID_ISAR6, DP) != 0; @@ -3351,6 +3356,11 @@ static inline bool isar_feature_aa64_dp(const ARMISARegisters *id) return FIELD_EX64(id->id_aa64isar0, ID_AA64ISAR0, DP) != 0; } +static inline bool isar_feature_aa64_jscvt(const ARMISARegisters *id) +{ + return FIELD_EX64(id->id_aa64isar1, ID_AA64ISAR1, JSCVT) != 0; +} + static inline bool isar_feature_aa64_fcma(const ARMISARegisters *id) { return FIELD_EX64(id->id_aa64isar1, ID_AA64ISAR1, FCMA) != 0; diff --git a/target/arm/helper.h b/target/arm/helper.h index 923e8e15255..747cb64d29f 100644 --- a/target/arm/helper.h +++ b/target/arm/helper.h @@ -218,6 +218,9 @@ DEF_HELPER_FLAGS_2(rintd_exact, TCG_CALL_NO_RWG, f64, f64, ptr) DEF_HELPER_FLAGS_2(rints, TCG_CALL_NO_RWG, f32, f32, ptr) DEF_HELPER_FLAGS_2(rintd, TCG_CALL_NO_RWG, f64, f64, ptr) +DEF_HELPER_FLAGS_2(vjcvt, TCG_CALL_NO_RWG, i32, f64, env) +DEF_HELPER_FLAGS_2(fjcvtzs, TCG_CALL_NO_RWG, i64, f64, ptr) + /* neon_helper.c */ DEF_HELPER_FLAGS_3(neon_qadd_u8, TCG_CALL_NO_RWG, i32, env, i32, i32) DEF_HELPER_FLAGS_3(neon_qadd_s8, TCG_CALL_NO_RWG, i32, env, i32, i32) diff --git a/target/arm/cpu.c b/target/arm/cpu.c index edf6e0e1f1c..8ea6569088d 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -2001,6 +2001,7 @@ static void arm_max_initfn(Object *obj) cpu->isar.id_isar5 = t; t = cpu->isar.id_isar6; + t = FIELD_DP32(t, ID_ISAR6, JSCVT, 1); t = FIELD_DP32(t, ID_ISAR6, DP, 1); cpu->isar.id_isar6 = t; diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c index eff0f164dd0..69e4134f79f 100644 --- a/target/arm/cpu64.c +++ b/target/arm/cpu64.c @@ -311,6 +311,7 @@ static void aarch64_max_initfn(Object *obj) cpu->isar.id_aa64isar0 = t; t = cpu->isar.id_aa64isar1; + t = FIELD_DP64(t, ID_AA64ISAR1, JSCVT, 1); t = FIELD_DP64(t, ID_AA64ISAR1, FCMA, 1); t = FIELD_DP64(t, ID_AA64ISAR1, APA, 1); /* PAuth, architected only */ t = FIELD_DP64(t, ID_AA64ISAR1, API, 0); @@ -344,6 +345,7 @@ static void aarch64_max_initfn(Object *obj) cpu->isar.id_isar5 = u; u = cpu->isar.id_isar6; + u = FIELD_DP32(u, ID_ISAR6, JSCVT, 1); u = FIELD_DP32(u, ID_ISAR6, DP, 1); cpu->isar.id_isar6 = u; diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c index dbce24fe32c..c56e878787c 100644 --- a/target/arm/translate-a64.c +++ b/target/arm/translate-a64.c @@ -6526,6 +6526,24 @@ static void handle_fmov(DisasContext *s, int rd, int rn, int type, bool itof) } } +static void handle_fjcvtzs(DisasContext *s, int rd, int rn) +{ + TCGv_i64 t = read_fp_dreg(s, rn); + TCGv_ptr fpstatus = get_fpstatus_ptr(false); + + gen_helper_fjcvtzs(t, t, fpstatus); + + tcg_temp_free_ptr(fpstatus); + + tcg_gen_ext32u_i64(cpu_reg(s, rd), t); + tcg_gen_extrh_i64_i32(cpu_ZF, t); + tcg_gen_movi_i32(cpu_CF, 0); + tcg_gen_movi_i32(cpu_NF, 0); + tcg_gen_movi_i32(cpu_VF, 0); + + tcg_temp_free_i64(t); +} + /* Floating point <-> integer conversions * 31 30 29 28 24 23 22 21 20 19 18 16 15 10 9 5 4 0 * +----+---+---+-----------+------+---+-------+-----+-------------+----+----+ @@ -6601,6 +6619,14 @@ static void disas_fp_int_conv(DisasContext *s, uint32_t insn) handle_fmov(s, rd, rn, type, itof); break; + case 0b00111110: /* FJCVTZS */ + if (!dc_isar_feature(aa64_jscvt, s)) { + goto do_unallocated; + } else if (fp_access_check(s)) { + handle_fjcvtzs(s, rd, rn); + } + break; + default: do_unallocated: unallocated_encoding(s); diff --git a/target/arm/translate.c b/target/arm/translate.c index 64c5fe0df3e..c1175798ac9 100644 --- a/target/arm/translate.c +++ b/target/arm/translate.c @@ -3718,6 +3718,13 @@ static int disas_vfp_insn(DisasContext *s, uint32_t insn) rm_is_dp = false; break; + case 0x13: /* vjcvt */ + if (!dp || !dc_isar_feature(aa32_jscvt, s)) { + return 1; + } + rd_is_dp = false; + break; + default: return 1; } @@ -4088,6 +4095,9 @@ static int disas_vfp_insn(DisasContext *s, uint32_t insn) case 17: /* fsito */ gen_vfp_sito(dp, 0); break; + case 19: /* vjcvt */ + gen_helper_vjcvt(cpu_F0s, cpu_F0d, cpu_env); + break; case 20: /* fshto */ gen_vfp_shto(dp, 16 - rm, 0); break; diff --git a/target/arm/vfp_helper.c b/target/arm/vfp_helper.c index 74d3030c471..cc7f9f5cb19 100644 --- a/target/arm/vfp_helper.c +++ b/target/arm/vfp_helper.c @@ -1086,3 +1086,91 @@ int arm_rmode_to_sf(int rmode) } return rmode; } + +/* + * Implement float64 to int32_t conversion without saturation; + * the result is supplied modulo 2^32. + */ +uint64_t HELPER(fjcvtzs)(float64 value, void *vstatus) +{ + float_status *status = vstatus; + uint32_t exp, sign; + uint64_t frac; + uint32_t inexact = 1; /* !Z */ + + sign = extract64(value, 63, 1); + exp = extract64(value, 52, 11); + frac = extract64(value, 0, 52); + + if (exp == 0) { + /* While not inexact for IEEE FP, -0.0 is inexact for JavaScript. */ + inexact = sign; + if (frac != 0) { + if (status->flush_inputs_to_zero) { + float_raise(float_flag_input_denormal, status); + } else { + float_raise(float_flag_inexact, status); + inexact = 1; + } + } + frac = 0; + } else if (exp == 0x7ff) { + /* This operation raises Invalid for both NaN and overflow (Inf). */ + float_raise(float_flag_invalid, status); + frac = 0; + } else { + int true_exp = exp - 1023; + int shift = true_exp - 52; + + /* Restore implicit bit. */ + frac |= 1ull << 52; + + /* Shift the fraction into place. */ + if (shift >= 0) { + /* The number is so large we must shift the fraction left. */ + if (shift >= 64) { + /* The fraction is shifted out entirely. */ + frac = 0; + } else { + frac <<= shift; + } + } else if (shift > -64) { + /* Normal case -- shift right and notice if bits shift out. */ + inexact = (frac << (64 + shift)) != 0; + frac >>= -shift; + } else { + /* The fraction is shifted out entirely. */ + frac = 0; + } + + /* Notice overflow or inexact exceptions. */ + if (true_exp > 31 || frac > (sign ? 0x80000000ull : 0x7fffffff)) { + /* Overflow, for which this operation raises invalid. */ + float_raise(float_flag_invalid, status); + inexact = 1; + } else if (inexact) { + float_raise(float_flag_inexact, status); + } + + /* Honor the sign. */ + if (sign) { + frac = -frac; + } + } + + /* Pack the result and the env->ZF representation of Z together. */ + return deposit64(frac, 32, 32, inexact); +} + +uint32_t HELPER(vjcvt)(float64 value, CPUARMState *env) +{ + uint64_t pair = HELPER(fjcvtzs)(value, &env->vfp.fp_status); + uint32_t result = pair; + uint32_t z = (pair >> 32) == 0; + + /* Store Z, clear NCV, in FPSCR.NZCV. */ + env->vfp.xregs[ARM_VFP_FPSCR] + = (env->vfp.xregs[ARM_VFP_FPSCR] & ~CPSR_NZCV) | (z * CPSR_Z); + + return result; +} From patchwork Thu Feb 21 18:57:26 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 158937 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp841076jaa; Thu, 21 Feb 2019 11:06:41 -0800 (PST) X-Google-Smtp-Source: AHgI3IYqN6cIEsK/hCNWCdUkSTDQtSA6REdGt0iAcnYy0+HkpBqGy+X17NfBN3/fQ/+PJLf3ODvj X-Received: by 2002:a25:8882:: with SMTP id d2mr19741ybl.381.1550776001867; Thu, 21 Feb 2019 11:06:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550776001; cv=none; d=google.com; s=arc-20160816; b=L4VIopnEOMs0XRoZQ8kSno7/29QwHDhit1s1WY9sH9rxqv80pHNWHrLsOTNLf5X2VP Q4lEY6V7Lr1uK5QEAShxrlSIAvZhbW8oAmjv7FwxkBVFrLAwXF3R+JOctKcagpwRoLGq zE0EqWxgiT38UK5IFAaSEpne/4CG5tRVxR+nym4/Bb1MMNK09LaUGCLOosUPG06Hjdf3 Et7b3Viyna+WDMVWh+XoSoUhtNn9yc/BtfFrpaNBzLGerk4FQB4sanZEMPHI237+SLzA 8MvOg2XMA2p2vRRmi5r+8jGVd763i2mXWbyDNg+dHXC0pAvEgssYVziDdAUOa4OGPLpF FGCg== 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=tZqUEGNvILINRMPY/6sZaASJERHi2DEhIKWOky+926w=; b=hEhm1s1WuKafaxLFRwHJ1hodmmXvI3MLDp4C+GWCadEeQVGiIsGDR9YR94P63X4OTT xL/2N3hHckhohl2UjDCmziXmUE/ICkG2bM3Xm2fJsdqj+z2R77wjgQCqQS89k11YRjZc LCtHNWX/E8c9icoeCav0qe320TsjZH6pyVtFb6yqukB+IPKY0L7KX+fGS4v+pZiUAFRr EaXMFQsPq72Ip9ne93C18yn1XH/VC4nHLMPa+mYp8aGbTzdyslANn23IAQXoP5e7P0wz rYgnJxTLP6W6FXshVteTwZaAzJOAdeUeAyZSkC1a5buE/t/8I04bD1/3vxOK5wp3XJMu uWqg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b="e7I/vAsJ"; 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 h18si13931346ybk.216.2019.02.21.11.06.41 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 21 Feb 2019 11:06:41 -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="e7I/vAsJ"; 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]:36958 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwtg9-0007PZ-9z for patch@linaro.org; Thu, 21 Feb 2019 14:06:41 -0500 Received: from eggs.gnu.org ([209.51.188.92]:52149) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwtXq-0008TS-8O for qemu-devel@nongnu.org; Thu, 21 Feb 2019 13:58:09 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gwtXo-0007Ru-R6 for qemu-devel@nongnu.org; Thu, 21 Feb 2019 13:58:06 -0500 Received: from mail-wr1-x42f.google.com ([2a00:1450:4864:20::42f]:41445) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gwtXn-0007Li-1F for qemu-devel@nongnu.org; Thu, 21 Feb 2019 13:58:03 -0500 Received: by mail-wr1-x42f.google.com with SMTP id n2so19643897wrw.8 for ; Thu, 21 Feb 2019 10:57:54 -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=tZqUEGNvILINRMPY/6sZaASJERHi2DEhIKWOky+926w=; b=e7I/vAsJe43Enl7TWch3Mr0dM79gwD7ZZl8y/kk73xQ4WKGmBhbStFnWB/EvYq0Ozo P7AbF6UpFALEzysd5xCzLnyU4SiT2uvaTCX/JzLqRJzwbUsQe2MSWy4lAXpHQyKmtwpd ckBcIzeVnxmJzB1H6auNW61PvCmo2N/OrR4xVJOc0x5dI5On1ZSrTnH8ug4N4g3Xtfps x75o2pdoDnCHdOp8cPyKDpDys4tgA53mfi/lXrBJy4OUb1/ucgba/krCrUaxsKIMnaTK WGI8OYyws1IM1BlI1Gm0n46ksjGpjLUcVp2wfGwvrIoL4Q2WpZfLacia6Vwy5b+RrI9w wvbQ== 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=tZqUEGNvILINRMPY/6sZaASJERHi2DEhIKWOky+926w=; b=IJJsrwJXM01yRKDnXoPuTT6tQxTKV/DmftIEFN0N915rqmudaB5mBRrWrzn1sZ0zga IueSWUYRp7n1Bqg/hRpZ5+z/h/yrSWYTZoDRcwtV0JVwOY3e7fYgxSdbhJYV6CCK844z BR687WnHL4cC9Ps8+YCeqjl0bp5FHcPfY1Wf4wGtHco9stEJn8D0zVSLgLCi4XTNzfVe KiFr0tJlj0r247Nxk2ag8J0/dI+Fig5gGo/5iCgTF0+cWDKTEJNHwnWuZyV1338DLrm1 d6aYMnYI5INruxQNnVtozg/Mzb9QxqoJd71CUYVRCMQH9Ws3EktiYcMUMLw8goQKguU4 FFTw== X-Gm-Message-State: AHQUAuaV/5/C4twVNhDtACzXYjq4JRu0mlcvQ6uIX9oHzhs8L/HZhKhe nhBcbB5sbUFfazp8W7qF9Y+E5o1tTOg= X-Received: by 2002:adf:e706:: with SMTP id c6mr6606wrm.278.1550775473239; Thu, 21 Feb 2019 10:57:53 -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.57.52 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 21 Feb 2019 10:57:52 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Date: Thu, 21 Feb 2019 18:57:26 +0000 Message-Id: <20190221185739.25362-9-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::42f Subject: [Qemu-devel] [PULL 08/21] hw/misc/tz-ppc: Support having unused ports in the middle of the range X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" The Peripheral Protection Controller's handling of unused ports is that if there is nothing connected to the port's downstream then it does not create the sysbus MMIO region for the upstream end of the port. This results in odd behaviour when there is an unused port in the middle of the range: since sysbus MMIO regions are implicitly consecutively allocated, any used ports above the unused ones end up with sysbus MMIO region numbers that don't match the port number. Avoid this numbering mismatch by creating dummy MMIO regions for the unused ports. This doesn't change anything for our existing boards, which don't have any gaps in the middle of the port ranges they use; but it will be needed for the Musca board. Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson --- include/hw/misc/tz-ppc.h | 8 +++++++- hw/misc/tz-ppc.c | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+), 1 deletion(-) -- 2.20.1 diff --git a/include/hw/misc/tz-ppc.h b/include/hw/misc/tz-ppc.h index fc8b806e4df..080d6e2ec17 100644 --- a/include/hw/misc/tz-ppc.h +++ b/include/hw/misc/tz-ppc.h @@ -38,7 +38,13 @@ * * QEMU interface: * + sysbus MMIO regions 0..15: MemoryRegions defining the upstream end - * of each of the 16 ports of the PPC + * of each of the 16 ports of the PPC. When a port is unused (i.e. no + * downstream MemoryRegion is connected to it) at the end of the 0..15 + * range then no sysbus MMIO region is created for its upstream. When an + * unused port lies in the middle of the range with other used ports at + * higher port numbers, a dummy MMIO region is created to ensure that + * port N's upstream is always sysbus MMIO region N. Dummy regions should + * not be mapped, and will assert if any access is made to them. * + Property "port[0..15]": MemoryRegion defining the downstream device(s) * for each of the 16 ports of the PPC * + Named GPIO inputs "cfg_nonsec[0..15]": set to 1 if the port should be diff --git a/hw/misc/tz-ppc.c b/hw/misc/tz-ppc.c index 3dd045c15f5..2e04837bea9 100644 --- a/hw/misc/tz-ppc.c +++ b/hw/misc/tz-ppc.c @@ -181,6 +181,21 @@ static const MemoryRegionOps tz_ppc_ops = { .endianness = DEVICE_LITTLE_ENDIAN, }; +static bool tz_ppc_dummy_accepts(void *opaque, hwaddr addr, + unsigned size, bool is_write, + MemTxAttrs attrs) +{ + /* + * Board code should never map the upstream end of an unused port, + * so we should never try to make a memory access to it. + */ + g_assert_not_reached(); +} + +static const MemoryRegionOps tz_ppc_dummy_ops = { + .valid.accepts = tz_ppc_dummy_accepts, +}; + static void tz_ppc_reset(DeviceState *dev) { TZPPC *s = TZ_PPC(dev); @@ -210,16 +225,33 @@ static void tz_ppc_realize(DeviceState *dev, Error **errp) SysBusDevice *sbd = SYS_BUS_DEVICE(dev); TZPPC *s = TZ_PPC(dev); int i; + int max_port = 0; /* We can't create the upstream end of the port until realize, * as we don't know the size of the MR used as the downstream until then. */ for (i = 0; i < TZ_NUM_PORTS; i++) { + if (s->port[i].downstream) { + max_port = i; + } + } + + for (i = 0; i <= max_port; i++) { TZPPCPort *port = &s->port[i]; char *name; uint64_t size; if (!port->downstream) { + /* + * Create dummy sysbus MMIO region so the sysbus region + * numbering doesn't get out of sync with the port numbers. + * The size is entirely arbitrary. + */ + name = g_strdup_printf("tz-ppc-dummy-port[%d]", i); + memory_region_init_io(&port->upstream, obj, &tz_ppc_dummy_ops, + port, name, 0x10000); + sysbus_init_mmio(sbd, &port->upstream); + g_free(name); continue; } From patchwork Thu Feb 21 18:57:27 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 158931 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp835272jaa; Thu, 21 Feb 2019 11:01:30 -0800 (PST) X-Google-Smtp-Source: AHgI3Ia0dm3RVKDgPc9OJThP9EEmVKFMTFN32w0fhjnnl3ff1gYr1TEIcG42yfIJyJyHHrSgyArN X-Received: by 2002:a25:3004:: with SMTP id w4mr33825810ybw.461.1550775690786; Thu, 21 Feb 2019 11:01:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550775690; cv=none; d=google.com; s=arc-20160816; b=SMk8MJXznudSkViQU/kPAjSjUcoC0m3mQymXiowkN6mIUAmETzc95Duk61fJ4FN60U M7xgASl+neNCsVHzTOkT4/zd8DArKKYe1CCfLkdH1fDym5XOGmKRHkxLyu9XgGz6amC3 TkUuqyXFrIDo6wFjRSCqRA80oJHsdZZjEnYj9agUNBNMy2QW1UvEJCvVyWgHOCKY2a/M 5a3JqUD9CfJkqiEBlPz+lmVa9oVOLvejBDXxJQnTDShUn62NbJ1r+hqwIWdYjxdlFFjT +qA2bHuO/Mghz0ordazey2e0LhnCH2vkE5ddrWVswbXVZ96MoNrNHAZI4YQ7itXjwEtF FwNQ== 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=1xlhf1mp9qqB33j+hK+JXtYtQaD6M2dVqgVLioh3iiM=; b=kST0neVP8VOdbSag8aHMmGf8CezujGK/P+iBtPjTun27HzOTCc0LTFcGR4roQWGM5f Fu2sPMl6zeHRTcy29hcL1ZBmOSMtE7T0NU1GT6mP+HSQAouxE5+jmR0UGlhnFJoXM4QS gu2n3b4tdqBXbGb/FcZfVADJ8eqJKigdLZ470dVLJgvYYSHDdQUZBFFjnE+7zUTqnVef uqgXnivz1RcxmM77ATC85UjJscVmZtAl6VTB8TabnjuJWTUWnA0JKso9/8KHk/sU23U5 X0MaFtS1Dcsbg5Xqks6vSRCF6+i5YM0udGY95Y5ZZnDeOORT/vL1xm3hZwOArQtPkI9J qdbA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=yoJcXXXJ; 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 s204si14336187ywb.44.2019.02.21.11.01.30 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 21 Feb 2019 11:01:30 -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=yoJcXXXJ; 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]:36931 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwtb8-0003ai-8G for patch@linaro.org; Thu, 21 Feb 2019 14:01:30 -0500 Received: from eggs.gnu.org ([209.51.188.92]:52065) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwtXn-0008QH-0x for qemu-devel@nongnu.org; Thu, 21 Feb 2019 13:58:04 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gwtXl-0007PP-50 for qemu-devel@nongnu.org; Thu, 21 Feb 2019 13:58:02 -0500 Received: from mail-wr1-x442.google.com ([2a00:1450:4864:20::442]:41810) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gwtXj-0007M7-9p for qemu-devel@nongnu.org; Thu, 21 Feb 2019 13:58:01 -0500 Received: by mail-wr1-x442.google.com with SMTP id n2so19643956wrw.8 for ; Thu, 21 Feb 2019 10:57:55 -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=1xlhf1mp9qqB33j+hK+JXtYtQaD6M2dVqgVLioh3iiM=; b=yoJcXXXJQHsR/94lZMFJE7NI2htQBItIjkspmC9MSTXVCRuTyr5EjhKvXbFu4+C/Zz JTlmYsrgQIc8X+XaPAnWo23qlPQx5jC5J1ZiTXDVyGBQ9YiWXPpVyWoe78VNe72VrHXY HKh1mj8xysBSwW3sqypWuQdx/n4BlARI4DatNJYWkqa8QkFCJXYEyfQg9BjG4IrL5Xv5 PDDFjWBUvwavq2hFKAQc2vEcwx91hOFxoF9nGAFmrHdiQgyPe+74HJ3/z/2NnouPC5Nf PbLacxTHxz4HzH0HTk7Vh1dtXpyJm/El4hECm5UfXZfqMQNJH3vT1XeqMGT5rgbIb/TM WNvg== 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=1xlhf1mp9qqB33j+hK+JXtYtQaD6M2dVqgVLioh3iiM=; b=UR0w4uuUeCey9WsRF/XAvAvmUgRKlez107zwZzwzmhRkzANS78UApmbL5Gi51UxiKI 4WkluJEaP3kbaUsVLVv5ePACRgdcbhcBlJKWm7ZXZ7oG8ULaC2b9oq2CK/ZZJrGWv2bF UiZrGySkv426kPv+PFimLybEVik8txen+GM5J1LXFh0Rc5r97kbHiBPv1FhsjJ8XnRMO zVf/yh0HXyYX4b/Um7xZwiPHLNha+EoeETyqQCkY+uci6QKfPg0xMKXmZdMfZ1wukPxI Hs1hMV/c21T/yDXA80cSqtH5fTGGaBEzFQShptY5rZIY70wcz0F/hFd84iKL2r3ZqknV NgFA== X-Gm-Message-State: AHQUAuaGB3eqMJJQzYYZ/fUiDFE7zC6yTl/fSQjDFyxYxfN/vwalP4ha jz6WskQ7qWgWuoTu76+Ewn9tJyjADks= X-Received: by 2002:adf:f391:: with SMTP id m17mr11380348wro.137.1550775474437; Thu, 21 Feb 2019 10:57:54 -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.57.53 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 21 Feb 2019 10:57:53 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Date: Thu, 21 Feb 2019 18:57:27 +0000 Message-Id: <20190221185739.25362-10-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::442 Subject: [Qemu-devel] [PULL 09/21] hw/timer/pl031: Allow use as an embedded-struct device 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" Create a new include file for the pl031's device struct, type macros, etc, so that it can be instantiated using the "embedded struct" coding style. Signed-off-by: Peter Maydell Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson --- include/hw/timer/pl031.h | 44 ++++++++++++++++++++++++++++++++++++++++ hw/timer/pl031.c | 25 +---------------------- MAINTAINERS | 1 + 3 files changed, 46 insertions(+), 24 deletions(-) create mode 100644 include/hw/timer/pl031.h -- 2.20.1 diff --git a/include/hw/timer/pl031.h b/include/hw/timer/pl031.h new file mode 100644 index 00000000000..99416d8ba52 --- /dev/null +++ b/include/hw/timer/pl031.h @@ -0,0 +1,44 @@ +/* + * ARM AMBA PrimeCell PL031 RTC + * + * Copyright (c) 2007 CodeSourcery + * + * This file is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * Contributions after 2012-01-13 are licensed under the terms of the + * GNU GPL, version 2 or (at your option) any later version. + */ + +#ifndef HW_TIMER_PL031 +#define HW_TIMER_PL031 + +#include "hw/sysbus.h" + +#define TYPE_PL031 "pl031" +#define PL031(obj) OBJECT_CHECK(PL031State, (obj), TYPE_PL031) + +typedef struct PL031State { + SysBusDevice parent_obj; + + MemoryRegion iomem; + QEMUTimer *timer; + qemu_irq irq; + + /* + * Needed to preserve the tick_count across migration, even if the + * absolute value of the rtc_clock is different on the source and + * destination. + */ + uint32_t tick_offset_vmstate; + uint32_t tick_offset; + + uint32_t mr; + uint32_t lr; + uint32_t cr; + uint32_t im; + uint32_t is; +} PL031State; + +#endif diff --git a/hw/timer/pl031.c b/hw/timer/pl031.c index d3aacce80da..f774dcd5223 100644 --- a/hw/timer/pl031.c +++ b/hw/timer/pl031.c @@ -12,6 +12,7 @@ */ #include "qemu/osdep.h" +#include "hw/timer/pl031.h" #include "hw/sysbus.h" #include "qemu/timer.h" #include "sysemu/sysemu.h" @@ -36,30 +37,6 @@ do { printf("pl031: " fmt , ## __VA_ARGS__); } while (0) #define RTC_MIS 0x18 /* Masked interrupt status register */ #define RTC_ICR 0x1c /* Interrupt clear register */ -#define TYPE_PL031 "pl031" -#define PL031(obj) OBJECT_CHECK(PL031State, (obj), TYPE_PL031) - -typedef struct PL031State { - SysBusDevice parent_obj; - - MemoryRegion iomem; - QEMUTimer *timer; - qemu_irq irq; - - /* Needed to preserve the tick_count across migration, even if the - * absolute value of the rtc_clock is different on the source and - * destination. - */ - uint32_t tick_offset_vmstate; - uint32_t tick_offset; - - uint32_t mr; - uint32_t lr; - uint32_t cr; - uint32_t im; - uint32_t is; -} PL031State; - static const unsigned char pl031_id[] = { 0x31, 0x10, 0x14, 0x00, /* Device ID */ 0x0d, 0xf0, 0x05, 0xb1 /* Cell ID */ diff --git a/MAINTAINERS b/MAINTAINERS index b1d786cfd87..db31bc4486c 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -491,6 +491,7 @@ F: hw/sd/pl181.c F: hw/ssi/pl022.c F: include/hw/ssi/pl022.h F: hw/timer/pl031.c +F: include/hw/timer/pl031.h F: include/hw/arm/primecell.h F: hw/timer/cmsdk-apb-timer.c F: include/hw/timer/cmsdk-apb-timer.h From patchwork Thu Feb 21 18:57:28 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 158939 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp842344jaa; Thu, 21 Feb 2019 11:07:45 -0800 (PST) X-Google-Smtp-Source: AHgI3IbwxOh7zC7JJuKFfNj69mlXbjxhteVvc6yimzNM7uKVvFOpyM1BVMjKSoDmBGfPsg+IXyCF X-Received: by 2002:a0d:d98f:: with SMTP id b137mr9265ywe.327.1550776064985; Thu, 21 Feb 2019 11:07:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550776064; cv=none; d=google.com; s=arc-20160816; b=Ezo3rYe4kCzEoovLaOkxsqapjOQB+piOirRNuY9nko+gWQj0brlnx3T8mWBNrtxI/z sPDshyhQ7l5YTBTxCi1Xn0LJu2jrdRGwT08lLbBzVy78W8EPxbVMx6SFCNKrRmnzQQQm Wccpu6JoixLfLqE2URy+7kKysnkeAwKnyPYNwBXD17pfv3Mqc/eiJyDjN6vqQShEkYxw dDBeh5J/ubAdW2Jago8/NSof1KJilcmNR9+gN7KZHF/aqOwdvLDBXQPbD0bmBcPXrmyB oT7m/DTEirUUgUzyTYUJC+PBq8x13R0lbXamFl2oZqyF0w5QwQ8OytpAImM3WXoBPsdZ n2Hg== 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=HI6U23/7J1J+W2Bgp+QyoxIJfvLjcjyO30TGVCDuwiI=; b=bubET68Pas15Ft1s4rSrn7Jpz+WmYWZlkysRjbAAtJuSsRQ8qjJTNAXTnjNetBcRpX QRGyDldKodZV4yj6M1PnAmMsKtD00/9Qra9Mhc0fTPg7eAdNdNdexo5aFsw1Ij1Ljj4o xV7lT+YMWTSdfqay3m8rCbs4eJryygFG2XVqBbSuLiIbvZ95ERd2B2zUDR3PQcVg0sS0 u4n6IAmCsFEAA8nMNNnWr1lpio0YpPkMjnpXj237W2RnBqV50DohcXYwIT52A3PVJvPJ RCJO2lHhH6B+JQXCVGX6kaZm8vnxb/S+A0WYvN68v9gmX2/xX9WKCq0INhKwEXI6dEx1 XVhA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=IcQO8PXO; 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 x84si13675850ywa.79.2019.02.21.11.07.44 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 21 Feb 2019 11:07:44 -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=IcQO8PXO; 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]:36996 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwthA-0008CT-CA for patch@linaro.org; Thu, 21 Feb 2019 14:07:44 -0500 Received: from eggs.gnu.org ([209.51.188.92]:52067) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwtXn-0008QJ-17 for qemu-devel@nongnu.org; Thu, 21 Feb 2019 13:58:04 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gwtXl-0007PS-5B for qemu-devel@nongnu.org; Thu, 21 Feb 2019 13:58:02 -0500 Received: from mail-wr1-x42b.google.com ([2a00:1450:4864:20::42b]:42053) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gwtXj-0007Mn-7t for qemu-devel@nongnu.org; Thu, 21 Feb 2019 13:58:01 -0500 Received: by mail-wr1-x42b.google.com with SMTP id r5so18445437wrg.9 for ; Thu, 21 Feb 2019 10:57:56 -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=HI6U23/7J1J+W2Bgp+QyoxIJfvLjcjyO30TGVCDuwiI=; b=IcQO8PXOOTuGWF+4w//kxLDiTgie3/SXcV3eZFulIhtSd1xZNW6gxxVF1NYqHsU2YB 3CrtOusCx8HHx9LUuHBlucUa2JHVgOQJIz6deq8Rt+qlPKbXlt3eBJCCsvkWGaLw2QVM YnSTdMwnVarDa7dG9wORJ+MBCWo4x0PhXafDSqg8cZNbfj3PZuwJkpRsXzKnuZcmM2Va wY+apaA7DhLGFPDT/x/1l6Vnul3InKpaIvZv9U48o285s0Xjh0mgbvfP0pTXI8eDKJzA L1V62gMXA9nCPhiUKs79x6SnWMdaW+KnFyanT+qb5FPoakkhhZbxDvHsRE0Hfqd+wH2v hdLw== 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=HI6U23/7J1J+W2Bgp+QyoxIJfvLjcjyO30TGVCDuwiI=; b=g52Upp5OQe8EpvZiCP0aZ7GB1tGIcLlshBFypwjvGSxa8/QiZ1BOd12+kMbCf7nA7/ wxY4+ujvSqkpalXRijrOmu1TDI2f8Ma2sZmDIdzkGcOB+SVTV8brRM2rcYm2zU0x4S7Y Ijq4kjWnPqt6ShxaqoHvnaV49wpoqsfKsJGoIrRvAbsxTOKXKXaU7sSV56r6ZRniOHaN MdofgadXCUkbJxch1qyPVLZ/yoKAcWhGEPaAh0eCgWxlw+ECHl8mLj3xH53Z2gJruxJZ TI8nlfST9EGloVbWoF+99oHrkWrmrqcOQmcDhpK5yBBLpt1wXmWN82/QOnhLIS6hareO HUTw== X-Gm-Message-State: AHQUAubwEmt0BwqkbSf3L+1rUUWJyBQ2kquJil+ND3D6ApBS3MjHuPZF 5cSHR4Ll/fKemhhygPzyfTLVT142+T0= X-Received: by 2002:adf:fa0d:: with SMTP id m13mr29205999wrr.93.1550775475642; Thu, 21 Feb 2019 10:57:55 -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.57.54 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 21 Feb 2019 10:57:54 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Date: Thu, 21 Feb 2019 18:57:28 +0000 Message-Id: <20190221185739.25362-11-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::42b Subject: [Qemu-devel] [PULL 10/21] hw/timer/pl031: Convert to using trace events 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" Convert the debug printing in the PL031 device to use trace events, and augment it to cover the interesting parts of device operation. Signed-off-by: Peter Maydell Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson --- hw/timer/pl031.c | 55 +++++++++++++++++++++++-------------------- hw/timer/trace-events | 6 +++++ 2 files changed, 36 insertions(+), 25 deletions(-) -- 2.20.1 diff --git a/hw/timer/pl031.c b/hw/timer/pl031.c index f774dcd5223..274ad47a33a 100644 --- a/hw/timer/pl031.c +++ b/hw/timer/pl031.c @@ -18,15 +18,7 @@ #include "sysemu/sysemu.h" #include "qemu/cutils.h" #include "qemu/log.h" - -//#define DEBUG_PL031 - -#ifdef DEBUG_PL031 -#define DPRINTF(fmt, ...) \ -do { printf("pl031: " fmt , ## __VA_ARGS__); } while (0) -#else -#define DPRINTF(fmt, ...) do {} while(0) -#endif +#include "trace.h" #define RTC_DR 0x00 /* Data read register */ #define RTC_MR 0x04 /* Match register */ @@ -44,7 +36,10 @@ static const unsigned char pl031_id[] = { static void pl031_update(PL031State *s) { - qemu_set_irq(s->irq, s->is & s->im); + uint32_t flags = s->is & s->im; + + trace_pl031_irq_state(flags); + qemu_set_irq(s->irq, flags); } static void pl031_interrupt(void * opaque) @@ -52,7 +47,7 @@ static void pl031_interrupt(void * opaque) PL031State *s = (PL031State *)opaque; s->is = 1; - DPRINTF("Alarm raised\n"); + trace_pl031_alarm_raised(); pl031_update(s); } @@ -69,7 +64,7 @@ static void pl031_set_alarm(PL031State *s) /* The timer wraps around. This subtraction also wraps in the same way, and gives correct results when alarm < now_ticks. */ ticks = s->mr - pl031_get_count(s); - DPRINTF("Alarm set in %ud ticks\n", ticks); + trace_pl031_set_alarm(ticks); if (ticks == 0) { timer_del(s->timer); pl031_interrupt(s); @@ -83,38 +78,49 @@ static uint64_t pl031_read(void *opaque, hwaddr offset, unsigned size) { PL031State *s = (PL031State *)opaque; - - if (offset >= 0xfe0 && offset < 0x1000) - return pl031_id[(offset - 0xfe0) >> 2]; + uint64_t r; switch (offset) { case RTC_DR: - return pl031_get_count(s); + r = pl031_get_count(s); + break; case RTC_MR: - return s->mr; + r = s->mr; + break; case RTC_IMSC: - return s->im; + r = s->im; + break; case RTC_RIS: - return s->is; + r = s->is; + break; case RTC_LR: - return s->lr; + r = s->lr; + break; case RTC_CR: /* RTC is permanently enabled. */ - return 1; + r = 1; + break; case RTC_MIS: - return s->is & s->im; + r = s->is & s->im; + break; + case 0xfe0 ... 0xfff: + r = pl031_id[(offset - 0xfe0) >> 2]; + break; case RTC_ICR: qemu_log_mask(LOG_GUEST_ERROR, "pl031: read of write-only register at offset 0x%x\n", (int)offset); + r = 0; break; default: qemu_log_mask(LOG_GUEST_ERROR, "pl031_read: Bad offset 0x%x\n", (int)offset); + r = 0; break; } - return 0; + trace_pl031_read(offset, r); + return r; } static void pl031_write(void * opaque, hwaddr offset, @@ -122,6 +128,7 @@ static void pl031_write(void * opaque, hwaddr offset, { PL031State *s = (PL031State *)opaque; + trace_pl031_write(offset, value); switch (offset) { case RTC_LR: @@ -134,7 +141,6 @@ static void pl031_write(void * opaque, hwaddr offset, break; case RTC_IMSC: s->im = value & 1; - DPRINTF("Interrupt mask %d\n", s->im); pl031_update(s); break; case RTC_ICR: @@ -142,7 +148,6 @@ static void pl031_write(void * opaque, hwaddr offset, cleared when bit 0 of the written value is set. However the arm926e documentation (DDI0287B) states that the interrupt is cleared when any value is written. */ - DPRINTF("Interrupt cleared"); s->is = 0; pl031_update(s); break; diff --git a/hw/timer/trace-events b/hw/timer/trace-events index 0144a68951c..12eb505fee7 100644 --- a/hw/timer/trace-events +++ b/hw/timer/trace-events @@ -77,3 +77,9 @@ xlnx_zynqmp_rtc_gettime(int year, int month, int day, int hour, int min, int sec nrf51_timer_read(uint64_t addr, uint32_t value, unsigned size) "read addr 0x%" PRIx64 " data 0x%" PRIx32 " size %u" nrf51_timer_write(uint64_t addr, uint32_t value, unsigned size) "write addr 0x%" PRIx64 " data 0x%" PRIx32 " size %u" +# hw/timer/pl031.c +pl031_irq_state(int level) "irq state %d" +pl031_read(uint32_t addr, uint32_t value) "addr 0x%08x value 0x%08x" +pl031_write(uint32_t addr, uint32_t value) "addr 0x%08x value 0x%08x" +pl031_alarm_raised(void) "alarm raised" +pl031_set_alarm(uint32_t ticks) "alarm set for %u ticks" From patchwork Thu Feb 21 18:57:29 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 158950 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp851551jaa; Thu, 21 Feb 2019 11:16:38 -0800 (PST) X-Google-Smtp-Source: AHgI3IbbbbghrS61hePKczj8Xpkpsu3fcjkUmAZZ6rZaiAhm9EeUkCQ5+wYyyaXv5sUUPy3WgNDq X-Received: by 2002:a5b:8:: with SMTP id a8mr89913ybp.75.1550776598937; Thu, 21 Feb 2019 11:16:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550776598; cv=none; d=google.com; s=arc-20160816; b=WaR8R4875CLQOriqJxIlQhDLHkjOJipx7hI/eTPwqoNVONO7dMZZbR84mxcfC6MQ8f TQx9pCK5otytSV0p4puga8GcWMZUDz70Jd/+zynU7GRpKX4yhgpb4geOMz9K551nN+2o fxudZ0dsgmd5CtCXJV4FsYwWfRY2F8v4ZelMXFpLsFbyU5FiZeu5BXrrcoxv6WCeaaF9 c0xJETMoPa33HX8ex6YUjHLabLqa6ItdBrmmJ1Co/llbFdf+U4lB+kMd+3sU5IN21K8E rRuFeGLC1hfwbpqbO8FeIMqSCSsMIcei/r8S/nkRcP79MC3YxPiHkOt0fxoO2v5quGTt edig== 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=SFWNo4DOeSTbEhbJ/U71HXoPGnhz14OVBzoHq8mGqTw=; b=uC1SzLlZefXIrHqqKseuGReWPUitBHVLwOEWRyXPdL1XGH85lFAC0ihMm0j0pcVeTR 7dNpW8rZbAOAkJS/PBEGhKTPRzcLgJl3JdKo2D4Ccu2ivrDk0emlsaRx0pBLfeTG1SEn frswY1A2w927+Bk9Ty1z8nAQ2LChEozn9X9FIRlGuVgcbh9Jfd7sRHmqF9klr/UB2l3G aSDi6fxPt1ZcKhllyPK+LtlTFfvMkiA8252FVFa/gln4zqsRZdmgJEMk21GI4FXGWFEn qnzTRhFCZ95iCF17v8DQatXPfy8YvzmQtaKy4z4rkbBHLsQXNJFkynMYgWywPD6hv7nB OjsQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Ol3uPvLk; 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 l5si12956958ywc.81.2019.02.21.11.16.38 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 21 Feb 2019 11:16:38 -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=Ol3uPvLk; 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]:37126 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwtpm-0006xQ-Be for patch@linaro.org; Thu, 21 Feb 2019 14:16:38 -0500 Received: from eggs.gnu.org ([209.51.188.92]:52157) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwtXq-0008Tw-Jy for qemu-devel@nongnu.org; Thu, 21 Feb 2019 13:58:09 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gwtXp-0007SP-18 for qemu-devel@nongnu.org; Thu, 21 Feb 2019 13:58:06 -0500 Received: from mail-wr1-x429.google.com ([2a00:1450:4864:20::429]:41440) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gwtXn-0007NM-8Z for qemu-devel@nongnu.org; Thu, 21 Feb 2019 13:58:04 -0500 Received: by mail-wr1-x429.google.com with SMTP id n2so19644084wrw.8 for ; Thu, 21 Feb 2019 10:57:57 -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=SFWNo4DOeSTbEhbJ/U71HXoPGnhz14OVBzoHq8mGqTw=; b=Ol3uPvLkxaM0GPCr4JU/XogLaJALqametMvTNCHQic48LLlHD/BN0YaDub1kd2keRv gUBOS0Eak3TzRlYcRYrCEp8/TcivTV4NuJAnt5+NuoFzHOiqaPX8mYS8jqzLx9tHqfgG LEfoc4b9kOrT+l3AMe2kAA2HxoCf009d0nXbEkUWJkLZAE5BLbqhI/rfA19hJfSi/nmj JXZQnESrKjZlhDN2DRkdAq/r7eZnfvEXsi8Lp+YqdMdi4+rM+DutKbZAab+X/iya3Vgt gGQkE+7fw1zwXTEv66Vfl1IjUS1iDyBWINQtQ7wqjgbw0tw58aaaD/t8XW+r2q3CVg3k h4sw== 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=SFWNo4DOeSTbEhbJ/U71HXoPGnhz14OVBzoHq8mGqTw=; b=cbc8mWpj8EjvjqVzFn4SsFGcr4yfbunAbM1vxtT0i0FNcs+uwT2UkmkNV4d1TXLyc1 vn1khTx1ZpiXBQylmBa3InqwIOxuVpokeEcJ8c4hZclr/JpKs6Y9Hj556SkFJzwoi8hO LV8pieoGDOUC25Qnp09hl0QBTje5C2JCEoVknC8ZqPY5ikZYcxLaxW3Pix0kX9bSjBBw LF2yn6BNlTpcAeZUcpRBoHWw9M8rV3ET/ICXjZs/7dn2RtVf3vg03r6Un0ufFQp9wqVg SxeEDw6rDSL07tCxg/ne2IYQnDyhU4tk1nyPCPvJjE/W/sd8onMg/jyMAN9ExASLpjC2 eKhA== X-Gm-Message-State: AHQUAubFsGcXOAWbus/4f+gL3PtfK07JivgqoqPHs8MWaxV/ZwthSydE n/64z1/20MWlUtUPbQC1zUvIy0oT6lM= X-Received: by 2002:adf:e487:: with SMTP id i7mr12176wrm.202.1550775476666; Thu, 21 Feb 2019 10:57:56 -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.57.55 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 21 Feb 2019 10:57:56 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Date: Thu, 21 Feb 2019 18:57:29 +0000 Message-Id: <20190221185739.25362-12-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::429 Subject: [Qemu-devel] [PULL 11/21] hw/char/pl011: Allow use as an embedded-struct device 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" Create a new include file for the pl011's device struct, type macros, etc, so that it can be instantiated using the "embedded struct" coding style. Signed-off-by: Peter Maydell Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson --- include/hw/char/pl011.h | 34 ++++++++++++++++++++++++++++++++++ hw/char/pl011.c | 31 ++----------------------------- 2 files changed, 36 insertions(+), 29 deletions(-) -- 2.20.1 diff --git a/include/hw/char/pl011.h b/include/hw/char/pl011.h index 83649324b6a..1b52bfd5c90 100644 --- a/include/hw/char/pl011.h +++ b/include/hw/char/pl011.h @@ -15,6 +15,40 @@ #ifndef HW_PL011_H #define HW_PL011_H +#include "hw/sysbus.h" +#include "chardev/char-fe.h" + +#define TYPE_PL011 "pl011" +#define PL011(obj) OBJECT_CHECK(PL011State, (obj), TYPE_PL011) + +/* This shares the same struct (and cast macro) as the base pl011 device */ +#define TYPE_PL011_LUMINARY "pl011_luminary" + +typedef struct PL011State { + SysBusDevice parent_obj; + + MemoryRegion iomem; + uint32_t readbuff; + uint32_t flags; + uint32_t lcr; + uint32_t rsr; + uint32_t cr; + uint32_t dmacr; + uint32_t int_enabled; + uint32_t int_level; + uint32_t read_fifo[16]; + uint32_t ilpr; + uint32_t ibrd; + uint32_t fbrd; + uint32_t ifl; + int read_pos; + int read_count; + int read_trigger; + CharBackend chr; + qemu_irq irq; + const unsigned char *id; +} PL011State; + static inline DeviceState *pl011_create(hwaddr addr, qemu_irq irq, Chardev *chr) diff --git a/hw/char/pl011.c b/hw/char/pl011.c index 2aa277fc4f2..0c4711e4027 100644 --- a/hw/char/pl011.c +++ b/hw/char/pl011.c @@ -8,39 +8,12 @@ */ #include "qemu/osdep.h" +#include "hw/char/pl011.h" #include "hw/sysbus.h" #include "chardev/char-fe.h" #include "qemu/log.h" #include "trace.h" -#define TYPE_PL011 "pl011" -#define PL011(obj) OBJECT_CHECK(PL011State, (obj), TYPE_PL011) - -typedef struct PL011State { - SysBusDevice parent_obj; - - MemoryRegion iomem; - uint32_t readbuff; - uint32_t flags; - uint32_t lcr; - uint32_t rsr; - uint32_t cr; - uint32_t dmacr; - uint32_t int_enabled; - uint32_t int_level; - uint32_t read_fifo[16]; - uint32_t ilpr; - uint32_t ibrd; - uint32_t fbrd; - uint32_t ifl; - int read_pos; - int read_count; - int read_trigger; - CharBackend chr; - qemu_irq irq; - const unsigned char *id; -} PL011State; - #define PL011_INT_TX 0x20 #define PL011_INT_RX 0x10 @@ -357,7 +330,7 @@ static void pl011_luminary_init(Object *obj) } static const TypeInfo pl011_luminary_info = { - .name = "pl011_luminary", + .name = TYPE_PL011_LUMINARY, .parent = TYPE_PL011, .instance_init = pl011_luminary_init, }; From patchwork Thu Feb 21 18:57:30 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 158945 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp847712jaa; Thu, 21 Feb 2019 11:12:55 -0800 (PST) X-Google-Smtp-Source: AHgI3IZ0AHjUWnxIbM2EQDiFEJuTQgy/9muaaOaO7YEbmN15sZHm85CxJtzvE7oaPCn5gCBCU20s X-Received: by 2002:a81:3c14:: with SMTP id j20mr75654ywa.324.1550776375635; Thu, 21 Feb 2019 11:12:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550776375; cv=none; d=google.com; s=arc-20160816; b=toVX20fAJEGpxKGneQXbp+WKYksw28cJdZaTXg6g+qwjC3ZilLwFIvVNU6c3TK3DM5 I1KYbsiP5Dk0u7C/4MXHgnC2A7cAT31Z/NwOEyL64JoS//4ZKHoLz4Al/O+JpIQnFeAD KhmIr863ko6NVmDBrpwHH7Iy7WD1OeMF9N5nw3qaQSRnZF5Zgz0tVVMc4cJyljeGmeyb mro4B51473T850FLXDtXCb0iX5znvuTv0MMokPEPlzwRuYuNheoJu/HKuFZt1ljIcD61 WvDdHjpUXnylMDqj6TzYrjbCGe+U3O+6DjWzz5a4DhwKEy6Q9p/acWsXmOcnQld+yA4c 2yfA== 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=CV0XuO7Jmju7b92elRHfSbeU/noy4D/dxWzQMm7SpKg=; b=fOsAzPbWyZYnvoEeIeVMYoKgf0v9+Weq4wkEcCc3zSuRrkzcZGiIxInk4wDUMSxVwq LOIi/QglIjRr0GxESJuW20OtM3Q/VP/Ygj+toF9uX2u57VslgvrqOsuffhSIYsm+5/Ra t8ltDjkIdkRE72XXq8WkFz179bXWsTH9w38gTg3y8cwrNZx2jQL1O+FYw4yqI5tOUA3b canvTVpUWdToPv0E2XNr/0km+xKbIdWL/FSqAZk2XFMo4rMPIxNn4+j4G4xtcOEhAZ6E tdLwzEm4ehKefjw/5pNiUhBtv7thYGJ1ImuTuAAOFZgnSszazSxCRhcH/ve3lJAawibU HJ8g== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=LjkCOz6T; 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 o200si7644283ywd.287.2019.02.21.11.12.55 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 21 Feb 2019 11:12:55 -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=LjkCOz6T; 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]:37074 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwtmB-0004e2-2S for patch@linaro.org; Thu, 21 Feb 2019 14:12:55 -0500 Received: from eggs.gnu.org ([209.51.188.92]:52165) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwtXq-0008UB-Nm for qemu-devel@nongnu.org; Thu, 21 Feb 2019 13:58:08 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gwtXp-0007SX-3N for qemu-devel@nongnu.org; Thu, 21 Feb 2019 13:58:06 -0500 Received: from mail-wm1-x343.google.com ([2a00:1450:4864:20::343]:36612) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gwtXo-0007Nr-HG for qemu-devel@nongnu.org; Thu, 21 Feb 2019 13:58:04 -0500 Received: by mail-wm1-x343.google.com with SMTP id j125so10314088wmj.1 for ; Thu, 21 Feb 2019 10:57:58 -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=CV0XuO7Jmju7b92elRHfSbeU/noy4D/dxWzQMm7SpKg=; b=LjkCOz6T+XgqaFiCPz0iM+efAj/5H4jwwW7ipWg05MP3ZttOP65tlnVyIkVTK712lZ T6zZpPuuCyCOEN1Wkixu3aLiGpzl0J9fkGR6pc9FryPmfWjhUPCx9cAqs9s7Q0IIxYIU TROwgnnfPrw0XgwYg6s3mdNuQPQFlfFaruF5O6lL0bOaIZDL8T1ZOKhpn5H6TFqj2oZZ oF2FSVNfo8tiR7pU2JJKTrOiOAsplWoRaVfj1KVZyUBihRMxn/It80PYRW1r4tVi0kL7 zQp1r5S+91wNYXb4kdSirCB2WHrThVvE0uenebB0AZH+FcHoCSk6eEwHAVeSQrxp4Rxr Z08Q== 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=CV0XuO7Jmju7b92elRHfSbeU/noy4D/dxWzQMm7SpKg=; b=K2j/3+tofi13NrebmchB04UP2FMSA6RldpX4Pp8oBOwcy0Snkw3N8fNHT0bGwQL4XA Q78oqIxyv/USsdu515q51V1lCGS9tyleO9EDmcYUkfd95kR8K618FRQ5gnPXM2psqwzM rtjyglGfQvbxsYxhNFZQmbhPcdWp15kstnow0yumn2kvpDe1yQJjlqKocqr+aVcPMJM6 4gZBEKQCiy26CgtnlKqIeVehGkV1e4ga7uXgUyRXGkuq2M8r8JGNADFEdf+pOI3AtKU2 N0LclK8nIw2lb4iF5YHohuIaXdq8CVHlTrQ/6uRImdh1yFk+9XrzLLf0IbdQOAur7YAz iuCw== X-Gm-Message-State: AHQUAubgtCdGKoTjSFeyShOWiUhxXxZ7hGztxkrHoXqxGbETJlywngQa CJXmdhGVTZoggxhENt+yTlpUvEZ7BT0= X-Received: by 2002:a1c:c282:: with SMTP id s124mr11158899wmf.105.1550775477726; Thu, 21 Feb 2019 10:57:57 -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.57.56 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 21 Feb 2019 10:57:57 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Date: Thu, 21 Feb 2019 18:57:30 +0000 Message-Id: <20190221185739.25362-13-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::343 Subject: [Qemu-devel] [PULL 12/21] hw/char/pl011: Support all interrupt lines X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" The PL011 UART has six interrupt lines: * RX (receive data) * TX (transmit data) * RT (receive timeout) * MS (modem status) * E (errors) * combined (logical OR of all the above) So far we have only emulated the combined interrupt line; add support for the others, so that boards that wire them up to different interrupt controller inputs can do so. Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson --- include/hw/char/pl011.h | 2 +- hw/char/pl011.c | 46 +++++++++++++++++++++++++++++++++++++++-- 2 files changed, 45 insertions(+), 3 deletions(-) -- 2.20.1 diff --git a/include/hw/char/pl011.h b/include/hw/char/pl011.h index 1b52bfd5c90..dad3cf29121 100644 --- a/include/hw/char/pl011.h +++ b/include/hw/char/pl011.h @@ -45,7 +45,7 @@ typedef struct PL011State { int read_count; int read_trigger; CharBackend chr; - qemu_irq irq; + qemu_irq irq[6]; const unsigned char *id; } PL011State; diff --git a/hw/char/pl011.c b/hw/char/pl011.c index 0c4711e4027..29f4e5eb224 100644 --- a/hw/char/pl011.c +++ b/hw/char/pl011.c @@ -7,6 +7,17 @@ * This code is licensed under the GPL. */ +/* + * QEMU interface: + * + sysbus MMIO region 0: device registers + * + sysbus IRQ 0: UARTINTR (combined interrupt line) + * + sysbus IRQ 1: UARTRXINTR (receive FIFO interrupt line) + * + sysbus IRQ 2: UARTTXINTR (transmit FIFO interrupt line) + * + sysbus IRQ 3: UARTRTINTR (receive timeout interrupt line) + * + sysbus IRQ 4: UARTMSINTR (momem status interrupt line) + * + sysbus IRQ 5: UARTEINTR (error interrupt line) + */ + #include "qemu/osdep.h" #include "hw/char/pl011.h" #include "hw/sysbus.h" @@ -22,18 +33,46 @@ #define PL011_FLAG_TXFF 0x20 #define PL011_FLAG_RXFE 0x10 +/* Interrupt status bits in UARTRIS, UARTMIS, UARTIMSC */ +#define INT_OE (1 << 10) +#define INT_BE (1 << 9) +#define INT_PE (1 << 8) +#define INT_FE (1 << 7) +#define INT_RT (1 << 6) +#define INT_TX (1 << 5) +#define INT_RX (1 << 4) +#define INT_DSR (1 << 3) +#define INT_DCD (1 << 2) +#define INT_CTS (1 << 1) +#define INT_RI (1 << 0) +#define INT_E (INT_OE | INT_BE | INT_PE | INT_FE) +#define INT_MS (INT_RI | INT_DSR | INT_DCD | INT_CTS) + static const unsigned char pl011_id_arm[8] = { 0x11, 0x10, 0x14, 0x00, 0x0d, 0xf0, 0x05, 0xb1 }; static const unsigned char pl011_id_luminary[8] = { 0x11, 0x00, 0x18, 0x01, 0x0d, 0xf0, 0x05, 0xb1 }; +/* Which bits in the interrupt status matter for each outbound IRQ line ? */ +static const uint32_t irqmask[] = { + INT_E | INT_MS | INT_RT | INT_TX | INT_RX, /* combined IRQ */ + INT_RX, + INT_TX, + INT_RT, + INT_MS, + INT_E, +}; + static void pl011_update(PL011State *s) { uint32_t flags; + int i; flags = s->int_level & s->int_enabled; trace_pl011_irq_state(flags != 0); - qemu_set_irq(s->irq, flags != 0); + for (i = 0; i < ARRAY_SIZE(s->irq); i++) { + qemu_set_irq(s->irq[i], (flags & irqmask[i]) != 0); + } } static uint64_t pl011_read(void *opaque, hwaddr offset, @@ -284,10 +323,13 @@ static void pl011_init(Object *obj) { SysBusDevice *sbd = SYS_BUS_DEVICE(obj); PL011State *s = PL011(obj); + int i; memory_region_init_io(&s->iomem, OBJECT(s), &pl011_ops, s, "pl011", 0x1000); sysbus_init_mmio(sbd, &s->iomem); - sysbus_init_irq(sbd, &s->irq); + for (i = 0; i < ARRAY_SIZE(s->irq); i++) { + sysbus_init_irq(sbd, &s->irq[i]); + } s->read_trigger = 1; s->ifl = 0x12; From patchwork Thu Feb 21 18:57:31 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 158940 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp842872jaa; Thu, 21 Feb 2019 11:08:17 -0800 (PST) X-Google-Smtp-Source: AHgI3IZKtCpv66jF2vI2SPi+lyRo9x8JaiK+DgdjN22sg2jaelpe/RqdfSkiIMUWzov/w3EuSH2C X-Received: by 2002:a81:83c8:: with SMTP id t191mr77473ywf.42.1550776097650; Thu, 21 Feb 2019 11:08:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550776097; cv=none; d=google.com; s=arc-20160816; b=V23tYQrlBoSDk/AyAcEbXPmgdnM6IgNq06DZEJ0Qh87TdG4dyU3Ad01U9UREV2eaDl foSBuu/ttQiXkX7o1vqbkpiht2a6WFlHyyqBMcQGttm26kvsVAAg7heiumkmZ1hyNeTb uo8a3u7P2Q2A7P+DfQwW+Vno4hzgxV3axJ09iLMzm/vKxdQmK5Ly8WPT+60yqBTYl5YG 8jZtBMZbwl9nuMROzyu43xDjI2mTqXDg+QPOubg5dz2cDMBGPdZ8zEOJVnDWOTjnLXqX L4dQXyv5V6HAO2pFMTAiCOMwx+ei/KJWYjEN8ITerBH+F1EgKIY4gDNodZcchZHgZDKW QmZQ== 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=aDzg/q6Ou+Q3G8inj+NI1UIvQeU4RYZ3ZNczYWKT/14=; b=dKouX/13Tl33VsWkBuIFCeQ8crRKmrnLlWo9EEgDTHFxbddYRQOC/Re6K1MC6X51lh YgLOWmBmXo0bxOhXHRQEhwXt+6jpnER584CcAfykUOxHbPchDvnmlFZVzMP1mkC9ERNr u0i+PLmwL9NU0xVjmztdS14al8Zb8iMaSx/i5bx1+rQH9VbsPVD4vfq+xo2VPE5gpj6n lU2oeXNMiM5oMjYGn+edF9u2dXL7I3Am+RZBh/dny6GsIepyuucj/YasQV8jKcxN0vbr E4m2K6xonclwA2DLvCCF/ub0e2IYDfKKHjAG8vheOVxyCPIZLYdRbSqNjQzds4A8KWOX xBHw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=A4F6Z8Xp; 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 n5si5069547ybh.59.2019.02.21.11.08.17 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 21 Feb 2019 11:08:17 -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=A4F6Z8Xp; 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]:37008 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwthh-0000u2-1y for patch@linaro.org; Thu, 21 Feb 2019 14:08:17 -0500 Received: from eggs.gnu.org ([209.51.188.92]:52102) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwtXo-0008S3-Ux for qemu-devel@nongnu.org; Thu, 21 Feb 2019 13:58:06 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gwtXn-0007Qw-1g for qemu-devel@nongnu.org; Thu, 21 Feb 2019 13:58:04 -0500 Received: from mail-wr1-x42f.google.com ([2a00:1450:4864:20::42f]:34632) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gwtXl-0007OW-4e for qemu-devel@nongnu.org; Thu, 21 Feb 2019 13:58:02 -0500 Received: by mail-wr1-x42f.google.com with SMTP id f14so31906694wrg.1 for ; Thu, 21 Feb 2019 10:57:59 -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=aDzg/q6Ou+Q3G8inj+NI1UIvQeU4RYZ3ZNczYWKT/14=; b=A4F6Z8XpjcsKr2vzelLDHuasDVsVuVh1hnsKSR/hCcyCHPpPQgn3H5Yy3R+XcAnAV7 pyGAv0zFcPyTJ9iz1jn7lKgN4NQDYXJd19nll8L8Tk02g7rXyEO3AzXcIoRjpGeTg2lQ duD5Q34EtsHSzQIhUNABkYiSS9Qp/NPmBbrKPMLw9HgQyLcAXwCfbtoL+yLJcerAINFc RyOI4LCRrC4Rc9SNIVMzCMMvXQVsGdklHWq7RljFWc+jTlG3rk44eTkHDxkHD6S7hz/+ 4jq66BYnGPmGIF9tKqlCFJpnhMMile/1H001JjwppA+t0X4KK7z9XQ3WI0H3d5A1ICZ3 HLNw== 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=aDzg/q6Ou+Q3G8inj+NI1UIvQeU4RYZ3ZNczYWKT/14=; b=hRNCYutxZJW9uus1Ycku9kCtpRd5Z1tp5sVhCUDYmkK3FF0aDThOFBX/WCFT0/O1+l anmXqD/HtUaExnm/hoOR7jXWahOi3JMRU0Y5X92Siluj3XiGU0TXuNlxB4YO6wm6VaTd G8d1wbasAgdLY2odzAg2t6YcDiqV8Gn1S5UkBUKnfatjyTKaDsb3hY43eOXBsfwcdheY sPRkDDsBFM3a78K2A8doShZNA9PaV2jAUUwkng7Fts9UsG02GAGMExiNva3ypTfvbmZW VNistDzgOPYRIRO/ZFCDWKHT5zz/uba3HG16DSXJi/Sk3I1snrWTKce43v13D4D9PZM3 jdbg== X-Gm-Message-State: AHQUAuaU+a246dluV8ltQKmWcT13WRuZ7a8N+XMdaN3fV49Wgez7AHkT 2wHVfaXCcxoDQlUH5MEjNkiQOAF4/vs= X-Received: by 2002:adf:d0c9:: with SMTP id z9mr17867wrh.132.1550775478778; Thu, 21 Feb 2019 10:57:58 -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.57.57 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 21 Feb 2019 10:57:58 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Date: Thu, 21 Feb 2019 18:57:31 +0000 Message-Id: <20190221185739.25362-14-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::42f Subject: [Qemu-devel] [PULL 13/21] hw/char/pl011: Use '0x' prefix when logging hex numbers X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" The pl011 logs when the guest makes a bad access. It prints the address offset in hex but confusingly omits the '0x' prefix; add it. Signed-off-by: Peter Maydell Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson --- hw/char/pl011.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) -- 2.20.1 diff --git a/hw/char/pl011.c b/hw/char/pl011.c index 29f4e5eb224..e5dd448f854 100644 --- a/hw/char/pl011.c +++ b/hw/char/pl011.c @@ -143,7 +143,7 @@ static uint64_t pl011_read(void *opaque, hwaddr offset, break; default: qemu_log_mask(LOG_GUEST_ERROR, - "pl011_read: Bad offset %x\n", (int)offset); + "pl011_read: Bad offset 0x%x\n", (int)offset); r = 0; break; } @@ -232,7 +232,7 @@ static void pl011_write(void *opaque, hwaddr offset, break; default: qemu_log_mask(LOG_GUEST_ERROR, - "pl011_write: Bad offset %x\n", (int)offset); + "pl011_write: Bad offset 0x%x\n", (int)offset); } } From patchwork Thu Feb 21 18:57:32 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 158948 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp848499jaa; Thu, 21 Feb 2019 11:13:42 -0800 (PST) X-Google-Smtp-Source: AHgI3IZ6xdV8k0l71Gm24fvVbDlPIAzEI7rBNt7XMfO02kvCOdvPbGiSITKy/KE03fHlmO27Avx0 X-Received: by 2002:a0d:ca0c:: with SMTP id m12mr102954ywd.70.1550776422574; Thu, 21 Feb 2019 11:13:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550776422; cv=none; d=google.com; s=arc-20160816; b=qILbz3QSpnd9dA5M1qPYKevbaexmpVqp81H3w+mhMF+rfNgGXh/TvGsxm3Rluy/jdw Q70s6MoOrb8xUgsyhzJgCxltpI+lY8DL55pdfO9oKpv9Sz3Z/xQF9ETjtqvneM425CEX vfPRULQAwFmC6f/tct0P9wx/EYyJBpQWgY1FGPKH8eUyuQkf9WcfGkj0OueshYgeXDz0 +cJcm7SvhX5A4RxdCTzB4UEXetVeZ1kKrj3Qc0AmoepCYT477pzHU4I1NyUs0Umj726C zwmRL9qAvo5UWf9AShSA8fn7wgIZ0XG4sLF+jjHldAz94k8PyT82bIOZbFJI1XogUEUQ W53g== 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=EMklLTyYA/DRen6XT5P4cvPzsOHEQguOgMPj7JOfY4k=; b=GpIsWr9W8cIrj9DqvK4crb8usfn7k0zRV8tZG0Nellh685+YGQDgTsnqTdKfg0UsKM iKEtlOWpsRvKNsCmdpFs19A0spl7B4IJ+MYn+fifb5JBNo6GNzr3fmU6aClU2pjD79C0 Y2y7z8V0mPmRq+zBWo6XA2Vi8U/Az9NNkARs6M+ZuZ1ajJbvVpl7s2Qdt5JjxpI1DAVK Up2PGMFDBrLqgwVGGZHMJv3jq2K7WpefzXFbdoZc8ZFWuoy7S9mB5QfuhADjBtVLECQ7 JceSzIr+ms8rjD8RNvxykgK6DC03LcB5Y05dqbxGMZXAIZ14xdCO47U5bNK9pubKrviQ ftZg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=xgLcMWIx; 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 o123si13079790yba.38.2019.02.21.11.13.42 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 21 Feb 2019 11:13:42 -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=xgLcMWIx; 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]:37070 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwtmw-0004UH-1Q for patch@linaro.org; Thu, 21 Feb 2019 14:13:42 -0500 Received: from eggs.gnu.org ([209.51.188.92]:52144) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwtXq-0008TL-5s for qemu-devel@nongnu.org; Thu, 21 Feb 2019 13:58:07 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gwtXo-0007S0-SQ for qemu-devel@nongnu.org; Thu, 21 Feb 2019 13:58:05 -0500 Received: from mail-wm1-x32e.google.com ([2a00:1450:4864:20::32e]:51456) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gwtXn-0007PC-1t for qemu-devel@nongnu.org; Thu, 21 Feb 2019 13:58:03 -0500 Received: by mail-wm1-x32e.google.com with SMTP id n19so10575305wmi.1 for ; Thu, 21 Feb 2019 10:58:01 -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=EMklLTyYA/DRen6XT5P4cvPzsOHEQguOgMPj7JOfY4k=; b=xgLcMWIxvX40dJ0Up1JPJbnjRG/Z+4oFI7O1flWfwp8eixHCokm/PUL08gI+Smm3HG 0NLMbV98BtFFjLp7vZCTyx6rVQ2eVJP8+0TRqBhnz8GXqYZueDkVapYd2TfUN0iNpvnf 8cNRiDs6khgE+5FdQuSFm8SjyQSKeTxGlnMHh+mrpa5RyVYSDPy6KRywwuhUfSd72Riz NxuLYU3ptcBzhKtbi7adBDb90rAujCJKgN0vujIr5Fk5YHppKvOxz6ZyVXQWBmM2JQrz hqZ50C98DJTCPN2yJm2d5WIej0W7h342x7/nxWEBatpE8ZfbmSG9U6PETHVspMjn0ROu U3yw== 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=EMklLTyYA/DRen6XT5P4cvPzsOHEQguOgMPj7JOfY4k=; b=d6/VQWSqJshkQ2NxLL/GkR3afPSrc3Z9JCWUTxgvJrpOTvQ/tTbLX2x9GWaZpqWAJJ SL4lUjozXJKD/XnZQHc9mYLquAswc4LujSTwcZpyitM/RxFH+CshCTW6oeCjbrxPsky/ fDAYbxVba7gP5RQpxtafKDYTl31VUH2bXsi2DmYsIst7szCrR8REarPe5hZ/frLDZrsA A55+JVOI0ExAK6Qq/XRjw67cFdW+6UcAvzJfE95uFEHoGgbbulVjO4tlFJTAVUDt1bHX llJCK8WTeeJDizFrBJYdZYJCFlSQfdCQEfXlWaNfAEMhrJUK9Dzv9W7acfaZNQHTSL4X ApHw== X-Gm-Message-State: AHQUAub+zmptn1HMRI5qKg/bPkA5MI6yNE+R1tvvbK8W/h9gxK5fWzgP odNQQhtJWWBmDahAIGSucU1W/uG6uQE= X-Received: by 2002:a1c:b1d5:: with SMTP id a204mr25539wmf.32.1550775479913; Thu, 21 Feb 2019 10:57:59 -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.57.58 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 21 Feb 2019 10:57:59 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Date: Thu, 21 Feb 2019 18:57:32 +0000 Message-Id: <20190221185739.25362-15-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::32e Subject: [Qemu-devel] [PULL 14/21] hw/arm/armsse: Document SRAM_ADDR_WIDTH property in header comment X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" In commit 4b635cf7a95e501211 we added a QOM property to the ARMSSE object, but forgot to add it to the documentation comment in the header. Correct the omission. Fixes: 4b635cf7a95e501211 ("hw/arm/armsse: Make SRAM bank size configurable") Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson --- include/hw/arm/armsse.h | 2 ++ 1 file changed, 2 insertions(+) -- 2.20.1 diff --git a/include/hw/arm/armsse.h b/include/hw/arm/armsse.h index f800bafb14a..444605b44dc 100644 --- a/include/hw/arm/armsse.h +++ b/include/hw/arm/armsse.h @@ -46,6 +46,8 @@ * being the same for both, to avoid having to have separate Property * lists for different variants. This restriction can be relaxed later * if necessary.) + * + QOM property "SRAM_ADDR_WIDTH" sets the number of bits used for the + * address of each SRAM bank (and thus the total amount of internal SRAM) * + Named GPIO inputs "EXP_IRQ" 0..n are the expansion interrupts for CPU 0, * which are wired to its NVIC lines 32 .. n+32 * + Named GPIO inputs "EXP_CPU1_IRQ" 0..n are the expansion interrupts for From patchwork Thu Feb 21 18:57:33 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 158938 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp841883jaa; Thu, 21 Feb 2019 11:07:20 -0800 (PST) X-Google-Smtp-Source: AHgI3IaZ/Ma0U+E9Z5cGMU24WMIHP71bOYudpFj/kYiNoCux94HUFAnuypLrDEEk0d7wexWy0DnT X-Received: by 2002:a81:24c2:: with SMTP id k185mr25830ywk.179.1550776040770; Thu, 21 Feb 2019 11:07:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550776040; cv=none; d=google.com; s=arc-20160816; b=nvf7+6mhV6sxvSCQQsAGPgMrQA4lSRFsFyR6a5U3sX5yZoVmK8he67zbNz4qnE9xmV Iy/QzXsVY4UantQAkCDmrvSHZShxo/o/9Br5g21PsXzFoQbc+qAOEu7gpfuCozKUzc6I yifBS7KlEycRmMnoIcMiLPAMKaOf/M+jIIh8U1rCslNt78HsahDURwfeXXDv+b5JaGOx fCQdP9HyOVgHJMhB4YQY52tN30ncMoPFam4oKPCqR65EGf6CuoR1cotEFcEylJEqWOV3 BaxXyCepygzGC6HMQuAWjzCqipUvwh+EgDnRTeaZwUpdCbc4TZzfQOgJcn7yzwgdNQZG Bp8Q== 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=6DwAcLSaFzva9ACId1E/asTJ9WH92ZHxCzcEEbU6fo4=; b=uZizE5OeSEwkpTlVaNwAGaXK0TuYOnm/lv5Azikk59DRJS8wYYIVA7LGc3NC97fLJf BSG83D0PkY3w5fcwTspfxhJ1VJ3ymePEr5oKwTBwcSiiuplPctLooVLDVEG97+sE1MlO p/KwWgTuW+BFQ0BeCVwVYqw/dC8N860fvfS0c3woz+0uPluPaiS/WpzoVhWfeDQ3hRAm MILVGCHNzAA09XUWg+3FbCKsPuMs3HHZX6e+UhZS4XNX+OHX6rkx0f39Mo2akKGN3AcK 17QqIDAVhZDtFN/YKWfugoDCseH9TxeYGejzqFP4Kg8JGiEU51h4QZ0JvMftCSnr6JYh iT+Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b="mm/hNaYr"; 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 k2si10579149ywb.253.2019.02.21.11.07.20 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 21 Feb 2019 11:07:20 -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="mm/hNaYr"; 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]:37002 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwtgl-0000Cq-O9 for patch@linaro.org; Thu, 21 Feb 2019 14:07:19 -0500 Received: from eggs.gnu.org ([209.51.188.92]:52193) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwtXr-0008Uv-HS for qemu-devel@nongnu.org; Thu, 21 Feb 2019 13:58:10 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gwtXp-0007Sr-9a for qemu-devel@nongnu.org; Thu, 21 Feb 2019 13:58:07 -0500 Received: from mail-wr1-x434.google.com ([2a00:1450:4864:20::434]:41451) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gwtXo-0007Pv-SM for qemu-devel@nongnu.org; Thu, 21 Feb 2019 13:58:05 -0500 Received: by mail-wr1-x434.google.com with SMTP id n2so19644307wrw.8 for ; Thu, 21 Feb 2019 10:58:02 -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=6DwAcLSaFzva9ACId1E/asTJ9WH92ZHxCzcEEbU6fo4=; b=mm/hNaYrCApiTTvGc/kB88zs47nh2Ucoti5Wiik2fxY2Y/a//0Rs4dYQO14uVz6e1d lgkQ5NjavUy0azuEXXuqcFRJqVkjqpx+gNL+hFDMdwHh4x7wuaDPtLd5r3/eo8/JJu2L EHybT8DyECfGEts9RX6fuvQeL8fSQxdh9owxPmO5hxmihZXDvO1yOhn8fUcBKYGfEcCC DKEhl1lebBuubEvtbye7TBEZ7pgTZyUFhVOHzy/w2vhAB0knnw4lHwaNuIJUMSj3U75L 5zk/1TOsU9hl6DxHr+TLp/Metcqg7b+N+GrDbQaI87m6cgQsqq2NJLlm29QNduAfR0tR V7oA== 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=6DwAcLSaFzva9ACId1E/asTJ9WH92ZHxCzcEEbU6fo4=; b=qZt8oFJS34YNiQWUBrxOZwbR9c7aQT6YshsXR25GODPaBpsOTSNcHKReiHNh87G4nw X+iGQSzdmKWprzLZMnK0KwUmQ+vH45vnZTWvgaQnBAxgPXwQQRmmf5PPCA4J48QsrwQE 2nUgnV28OZ1WIgX1eY86SsxvNO0G5IB4ETx3DqByxpstYJKoTb6gKxU2whJKj22IpcVb +yRGP/0y+BroxqbVRo0R4l/sNhaB4y/oMCMla+h+t362KrE1Xuho/j0f47ner6uTIydh LMeod3LzAQEgGC90gnMu1iiQLNKYVdlV3gi4XUEioORxmFl+o9G2jR0NUduXQprG6at/ zk+g== X-Gm-Message-State: AHQUAuYyL2WaXZV+jtRFQNE9QpLTaxxXDCQ2Ut3hxmCzMy4npKBdoMI/ K6l20rX7IRz0nCNLnJqxVAfmJUOFGGk= X-Received: by 2002:adf:fc12:: with SMTP id i18mr28307069wrr.201.1550775481089; Thu, 21 Feb 2019 10:58:01 -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.57.59 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 21 Feb 2019 10:58:00 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Date: Thu, 21 Feb 2019 18:57:33 +0000 Message-Id: <20190221185739.25362-16-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::434 Subject: [Qemu-devel] [PULL 15/21] hw/arm/armsse: Allow boards to specify init-svtor X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" The Musca boards have DAPLink firmware that sets the initial secure VTOR value (the location of the vector table) differently depending on the boot mode (from flash, from RAM, etc). Export the init-svtor as a QOM property of the ARMSSE object so that the board can change it. Signed-off-by: Peter Maydell Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson --- include/hw/arm/armsse.h | 3 +++ hw/arm/armsse.c | 8 ++++---- 2 files changed, 7 insertions(+), 4 deletions(-) -- 2.20.1 diff --git a/include/hw/arm/armsse.h b/include/hw/arm/armsse.h index 444605b44dc..84879f40dd8 100644 --- a/include/hw/arm/armsse.h +++ b/include/hw/arm/armsse.h @@ -48,6 +48,8 @@ * if necessary.) * + QOM property "SRAM_ADDR_WIDTH" sets the number of bits used for the * address of each SRAM bank (and thus the total amount of internal SRAM) + * + QOM property "init-svtor" sets the initial value of the CPU SVTOR register + * (where it expects to load the PC and SP from the vector table on reset) * + Named GPIO inputs "EXP_IRQ" 0..n are the expansion interrupts for CPU 0, * which are wired to its NVIC lines 32 .. n+32 * + Named GPIO inputs "EXP_CPU1_IRQ" 0..n are the expansion interrupts for @@ -204,6 +206,7 @@ typedef struct ARMSSE { uint32_t exp_numirq; uint32_t mainclk_frq; uint32_t sram_addr_width; + uint32_t init_svtor; } ARMSSE; typedef struct ARMSSEInfo ARMSSEInfo; diff --git a/hw/arm/armsse.c b/hw/arm/armsse.c index d0207dbabc7..50da41f64c5 100644 --- a/hw/arm/armsse.c +++ b/hw/arm/armsse.c @@ -505,11 +505,10 @@ static void armsse_realize(DeviceState *dev, Error **errp) * the INITSVTOR* registers before powering up the CPUs in any case, * so the hardware's default value doesn't matter. QEMU doesn't emulate * the control processor, so instead we behave in the way that the - * firmware does. All boards currently known about have firmware that - * sets the INITSVTOR0 and INITSVTOR1 registers to 0x10000000, like the - * IoTKit default. We can make this more configurable if necessary. + * firmware does. The initial value is configurable by the board code + * to match whatever its firmware does. */ - qdev_prop_set_uint32(cpudev, "init-svtor", 0x10000000); + qdev_prop_set_uint32(cpudev, "init-svtor", s->init_svtor); /* * Start all CPUs except CPU0 powered down. In real hardware it is * a configurable property of the SSE-200 which CPUs start powered up @@ -1187,6 +1186,7 @@ static Property armsse_properties[] = { DEFINE_PROP_UINT32("EXP_NUMIRQ", ARMSSE, exp_numirq, 64), DEFINE_PROP_UINT32("MAINCLK", ARMSSE, mainclk_frq, 0), DEFINE_PROP_UINT32("SRAM_ADDR_WIDTH", ARMSSE, sram_addr_width, 15), + DEFINE_PROP_UINT32("init-svtor", ARMSSE, init_svtor, 0x10000000), DEFINE_PROP_END_OF_LIST() }; From patchwork Thu Feb 21 18:57:34 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 158955 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp856709jaa; Thu, 21 Feb 2019 11:21:54 -0800 (PST) X-Google-Smtp-Source: AHgI3IY0uqm3X76HynMVKRuUJob8eZpoGkfPOiz675XEksue7CnQGEJO53JbCSnAiuPyU5v5u2/s X-Received: by 2002:a81:9a08:: with SMTP id r8mr91822ywg.135.1550776914477; Thu, 21 Feb 2019 11:21:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550776914; cv=none; d=google.com; s=arc-20160816; b=xlTddkJsiRdhBYoIP5oKjs8Gdt809rONp2RFwhpN9HgkW4nYsbNECbgaK/jY3BQp3e TyXooev2WEjAfaeDILWZj7gVLymkxL16ArwA26sf264lPE+p3+u0wsz4F1RHQHSGhj6U Hqgxmb8zg5b5YtJ+Z+BmpW8Ee5Jhs+7kxeUy7hb8J59ZD7m2UDaJEGx31yd9w1YfYDZX 4GtnbOlORQbAWyvhxqj65/Aw1wOa3N+hJyGSMcD2vgoZGcltr2HLyX8PpVBcJZOtX6eD 9xRpCVTmYHaAbugZpMHpNrpm5u58J/O2WPSpo4zyabuwsIHkPE9ui4YIWcQbW5yLNFQD ayRQ== 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=gCXyU11T1J3Limbvn3CrmF3kemF7dRHp5A3mozhNwMM=; b=GnnEwuf63ApRmRj2wP6h782F9xt16DHI9HRLE0EMLMOJfLSnAU/o7FmRR3lWf35Nu/ kKWLKwVDmXVNFplIYoyYffqD6/yz8FY53mXNMSUKk9LMys0Y5y3zaPMJqZbLl5Z11QRK vv+C9h4B2pIA1ofNncrt0hsiCjn7JyoP875VUvW86gMqqwgDwsJ+f3RDyI2iA6cr8a3S 4gfUlHsBhvTD0Dnqlc2CGPzsGIVOn0wmz1uKvlk0mEuL61XFAxQYRn78Ua7siRGvbKRk d9ZMkRtNWIOQqXURa8kMLZ7fvo43udy1qp6exuHhZvNxRrGQqem7U91UUKJMJpVL1Q+a mLaw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=FPTGdLhe; 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 k11si13586188ybp.325.2019.02.21.11.21.54 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 21 Feb 2019 11:21:54 -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=FPTGdLhe; 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]:37231 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwtur-0003Ug-W8 for patch@linaro.org; Thu, 21 Feb 2019 14:21:54 -0500 Received: from eggs.gnu.org ([209.51.188.92]:52239) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwtXt-000059-5h for qemu-devel@nongnu.org; Thu, 21 Feb 2019 13:58:11 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gwtXp-0007Sx-CO for qemu-devel@nongnu.org; Thu, 21 Feb 2019 13:58:09 -0500 Received: from mail-wr1-x432.google.com ([2a00:1450:4864:20::432]:47080) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gwtXp-0007R6-0G for qemu-devel@nongnu.org; Thu, 21 Feb 2019 13:58:05 -0500 Received: by mail-wr1-x432.google.com with SMTP id i16so23569538wrs.13 for ; Thu, 21 Feb 2019 10:58:03 -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=gCXyU11T1J3Limbvn3CrmF3kemF7dRHp5A3mozhNwMM=; b=FPTGdLhectnqtnXKqd5FxMSwdhBatARfE0cGf+LLn+LedU8xLs2eyD2ncyb+sv/byi vAlZJnff8RMGdAyEohJHZsr25rOSQ640E4iSBuz1lXutdM/lb2AUsyh7hnAc95TvR53n o8/1GgmCvktZTeeTPqp3d1ikyrsfThbOEgwLNVYgnuwD/imdMifNk7WxCCXmvYAoYP4y tThx1EH6vpKX4ZMh3CGtXrgyQwmvAK3Fu7UlomTeL/1APU7Pe8FvNNRjRvMZaUkQTQUa JdtHHKqnvEdcQADWMQzU4ueF0H6MBOACf9sJwiEcMddXHPiGp5oPP/wtNewDQW3Guvma rIJA== 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=gCXyU11T1J3Limbvn3CrmF3kemF7dRHp5A3mozhNwMM=; b=NLX/it+/oYoU5u4zQXbRoxq1r+CxICrBQcbRvXZoTkVdxZwJXcvTAzsXdBz64RuHKj LdraUbw43m4EOnDtgosKg+WPvcYjdEQbGcT7hxRJHTG9bQfHIq/EuZo8uiYG/OW4Sa8s HewfR83REJfp8pYDvJpuvisPptUc0dZmoDG/fXBiPBYoYVJHuJCkvQy+MEjmbsmE8bq+ koraY6tJsjoN+tA3IbI2Js2kGhWxQNZjRDzDFVVTEujvfTf2ux1hfODdt6wk9dsn4SSY 3ZZ/liPFQLMRNF/BTxRZtfVBlZetPeXxF5ACOTAYCyjl8PmRUJ8o5+ZNK86IGwmaLC/t 2DBw== X-Gm-Message-State: AHQUAubkbeuSqnZd7GTsXP9DeIKVQtzW2ZId4ItL3noqMJMrdoMzoM+5 pxma8tIlWKFDGXIgYSSddGucuRtmeuo= X-Received: by 2002:adf:c543:: with SMTP id s3mr13680wrf.192.1550775482337; Thu, 21 Feb 2019 10:58:02 -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.01 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 21 Feb 2019 10:58:01 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Date: Thu, 21 Feb 2019 18:57:34 +0000 Message-Id: <20190221185739.25362-17-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::432 Subject: [Qemu-devel] [PULL 16/21] hw/arm/musca.c: Implement models of the Musca-A and -B1 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" The Musca-A and Musca-B1 development boards are based on the SSE-200 subsystem for embedded. Implement an initial skeleton model of these boards, which are similar but not identical. This commit creates the board model with the SSE and the IRQ splitters to wire IRQs up to its two CPUs. As yet there are no devices and no memory: these will be added later. Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson --- hw/arm/Makefile.objs | 1 + hw/arm/musca.c | 197 ++++++++++++++++++++++++++++++++ MAINTAINERS | 6 + default-configs/arm-softmmu.mak | 1 + 4 files changed, 205 insertions(+) create mode 100644 hw/arm/musca.c -- 2.20.1 diff --git a/hw/arm/Makefile.objs b/hw/arm/Makefile.objs index fa40e8d6412..fa57c7c7704 100644 --- a/hw/arm/Makefile.objs +++ b/hw/arm/Makefile.objs @@ -35,6 +35,7 @@ obj-$(CONFIG_ASPEED_SOC) += aspeed_soc.o aspeed.o obj-$(CONFIG_MPS2) += mps2.o obj-$(CONFIG_MPS2) += mps2-tz.o obj-$(CONFIG_MSF2) += msf2-soc.o msf2-som.o +obj-$(CONFIG_MUSCA) += musca.o obj-$(CONFIG_ARMSSE) += armsse.o obj-$(CONFIG_FSL_IMX7) += fsl-imx7.o mcimx7d-sabre.o obj-$(CONFIG_ARM_SMMUV3) += smmu-common.o smmuv3.o diff --git a/hw/arm/musca.c b/hw/arm/musca.c new file mode 100644 index 00000000000..cc624c7d160 --- /dev/null +++ b/hw/arm/musca.c @@ -0,0 +1,197 @@ +/* + * Arm Musca-B1 test chip board emulation + * + * Copyright (c) 2019 Linaro Limited + * Written by Peter Maydell + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 or + * (at your option) any later version. + */ + +/* + * The Musca boards are a reference implementation of a system using + * the SSE-200 subsystem for embedded: + * https://developer.arm.com/products/system-design/development-boards/iot-test-chips-and-boards/musca-a-test-chip-board + * https://developer.arm.com/products/system-design/development-boards/iot-test-chips-and-boards/musca-b-test-chip-board + * We model the A and B1 variants of this board, as described in the TRMs: + * http://infocenter.arm.com/help/topic/com.arm.doc.101107_0000_00_en/index.html + * http://infocenter.arm.com/help/topic/com.arm.doc.101312_0000_00_en/index.html + */ + +#include "qemu/osdep.h" +#include "qemu/error-report.h" +#include "qapi/error.h" +#include "exec/address-spaces.h" +#include "hw/arm/arm.h" +#include "hw/arm/armsse.h" +#include "hw/boards.h" +#include "hw/core/split-irq.h" + +#define MUSCA_NUMIRQ_MAX 96 + +typedef enum MuscaType { + MUSCA_A, + MUSCA_B1, +} MuscaType; + +typedef struct { + MachineClass parent; + MuscaType type; + uint32_t init_svtor; + int sram_addr_width; + int num_irqs; +} MuscaMachineClass; + +typedef struct { + MachineState parent; + + ARMSSE sse; + SplitIRQ cpu_irq_splitter[MUSCA_NUMIRQ_MAX]; +} MuscaMachineState; + +#define TYPE_MUSCA_MACHINE "musca" +#define TYPE_MUSCA_A_MACHINE MACHINE_TYPE_NAME("musca-a") +#define TYPE_MUSCA_B1_MACHINE MACHINE_TYPE_NAME("musca-b1") + +#define MUSCA_MACHINE(obj) \ + OBJECT_CHECK(MuscaMachineState, obj, TYPE_MUSCA_MACHINE) +#define MUSCA_MACHINE_GET_CLASS(obj) \ + OBJECT_GET_CLASS(MuscaMachineClass, obj, TYPE_MUSCA_MACHINE) +#define MUSCA_MACHINE_CLASS(klass) \ + OBJECT_CLASS_CHECK(MuscaMachineClass, klass, TYPE_MUSCA_MACHINE) + +/* + * Main SYSCLK frequency in Hz + * TODO this should really be different for the two cores, but we + * don't model that in our SSE-200 model yet. + */ +#define SYSCLK_FRQ 40000000 + +static void musca_init(MachineState *machine) +{ + MuscaMachineState *mms = MUSCA_MACHINE(machine); + MuscaMachineClass *mmc = MUSCA_MACHINE_GET_CLASS(mms); + MachineClass *mc = MACHINE_GET_CLASS(machine); + MemoryRegion *system_memory = get_system_memory(); + DeviceState *ssedev; + int i; + + assert(mmc->num_irqs <= MUSCA_NUMIRQ_MAX); + + if (strcmp(machine->cpu_type, mc->default_cpu_type) != 0) { + error_report("This board can only be used with CPU %s", + mc->default_cpu_type); + exit(1); + } + + sysbus_init_child_obj(OBJECT(machine), "sse-200", &mms->sse, + sizeof(mms->sse), TYPE_SSE200); + ssedev = DEVICE(&mms->sse); + object_property_set_link(OBJECT(&mms->sse), OBJECT(system_memory), + "memory", &error_fatal); + qdev_prop_set_uint32(ssedev, "EXP_NUMIRQ", mmc->num_irqs); + qdev_prop_set_uint32(ssedev, "init-svtor", mmc->init_svtor); + qdev_prop_set_uint32(ssedev, "SRAM_ADDR_WIDTH", mmc->sram_addr_width); + qdev_prop_set_uint32(ssedev, "MAINCLK", SYSCLK_FRQ); + object_property_set_bool(OBJECT(&mms->sse), true, "realized", + &error_fatal); + + /* + * We need to create splitters to feed the IRQ inputs + * for each CPU in the SSE-200 from each device in the board. + */ + for (i = 0; i < mmc->num_irqs; i++) { + char *name = g_strdup_printf("musca-irq-splitter%d", i); + SplitIRQ *splitter = &mms->cpu_irq_splitter[i]; + + object_initialize_child(OBJECT(machine), name, + splitter, sizeof(*splitter), + TYPE_SPLIT_IRQ, &error_fatal, NULL); + g_free(name); + + object_property_set_int(OBJECT(splitter), 2, "num-lines", + &error_fatal); + object_property_set_bool(OBJECT(splitter), true, "realized", + &error_fatal); + qdev_connect_gpio_out(DEVICE(splitter), 0, + qdev_get_gpio_in_named(ssedev, "EXP_IRQ", i)); + qdev_connect_gpio_out(DEVICE(splitter), 1, + qdev_get_gpio_in_named(ssedev, + "EXP_CPU1_IRQ", i)); + } + + armv7m_load_kernel(ARM_CPU(first_cpu), machine->kernel_filename, 0x2000000); +} + +static void musca_class_init(ObjectClass *oc, void *data) +{ + MachineClass *mc = MACHINE_CLASS(oc); + + mc->default_cpus = 2; + mc->min_cpus = mc->default_cpus; + mc->max_cpus = mc->default_cpus; + mc->default_cpu_type = ARM_CPU_TYPE_NAME("cortex-m33"); + mc->init = musca_init; +} + +static void musca_a_class_init(ObjectClass *oc, void *data) +{ + MachineClass *mc = MACHINE_CLASS(oc); + MuscaMachineClass *mmc = MUSCA_MACHINE_CLASS(oc); + + mc->desc = "ARM Musca-A board (dual Cortex-M33)"; + mmc->type = MUSCA_A; + mmc->init_svtor = 0x10200000; + mmc->sram_addr_width = 15; + mmc->num_irqs = 64; +} + +static void musca_b1_class_init(ObjectClass *oc, void *data) +{ + MachineClass *mc = MACHINE_CLASS(oc); + MuscaMachineClass *mmc = MUSCA_MACHINE_CLASS(oc); + + mc->desc = "ARM Musca-B1 board (dual Cortex-M33)"; + mmc->type = MUSCA_B1; + /* + * This matches the DAPlink firmware which boots from QSPI. There + * is also a firmware blob which boots from the eFlash, which + * uses init_svtor = 0x1A000000. QEMU doesn't currently support that, + * though we could in theory expose a machine property on the command + * line to allow the user to request eFlash boot. + */ + mmc->init_svtor = 0x10000000; + mmc->sram_addr_width = 17; + mmc->num_irqs = 96; +} + +static const TypeInfo musca_info = { + .name = TYPE_MUSCA_MACHINE, + .parent = TYPE_MACHINE, + .abstract = true, + .instance_size = sizeof(MuscaMachineState), + .class_size = sizeof(MuscaMachineClass), + .class_init = musca_class_init, +}; + +static const TypeInfo musca_a_info = { + .name = TYPE_MUSCA_A_MACHINE, + .parent = TYPE_MUSCA_MACHINE, + .class_init = musca_a_class_init, +}; + +static const TypeInfo musca_b1_info = { + .name = TYPE_MUSCA_B1_MACHINE, + .parent = TYPE_MUSCA_MACHINE, + .class_init = musca_b1_class_init, +}; + +static void musca_machine_init(void) +{ + type_register_static(&musca_info); + type_register_static(&musca_a_info); + type_register_static(&musca_b1_info); +} + +type_init(musca_machine_init); diff --git a/MAINTAINERS b/MAINTAINERS index db31bc4486c..6ae55ff7323 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -634,6 +634,12 @@ F: include/hw/misc/iotkit-sysinfo.h F: hw/misc/armsse-cpuid.c F: include/hw/misc/armsse-cpuid.h +Musca +M: Peter Maydell +L: qemu-arm@nongnu.org +S: Maintained +F: hw/arm/musca.c + Musicpal M: Jan Kiszka M: Peter Maydell diff --git a/default-configs/arm-softmmu.mak b/default-configs/arm-softmmu.mak index 734ca721e9e..87ad2674946 100644 --- a/default-configs/arm-softmmu.mak +++ b/default-configs/arm-softmmu.mak @@ -89,6 +89,7 @@ CONFIG_TUSB6010=y CONFIG_IMX=y CONFIG_MAINSTONE=y CONFIG_MPS2=y +CONFIG_MUSCA=y CONFIG_NSERIES=y CONFIG_RASPI=y CONFIG_REALVIEW=y From patchwork Thu Feb 21 18:57:35 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 158956 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp859948jaa; Thu, 21 Feb 2019 11:25:31 -0800 (PST) X-Google-Smtp-Source: AHgI3IazmMNT9AkIh09//IzgDmCikt9qe7Lf76vYmWplAp0v+Ip5IrDkkQGG/hqIVoC4hevIK5Lb X-Received: by 2002:a25:e904:: with SMTP id n4mr133092ybd.480.1550777131217; Thu, 21 Feb 2019 11:25:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550777131; cv=none; d=google.com; s=arc-20160816; b=C2lZzrIp9z+xLfUCW9lfnWelbGn1SDWFh6PrsEenbeSHG359u97W3TbrkaeDMhyVGG z24XesgU6a37ZzgLyZBYXUfuzFZ1yqnDFqes2l+S7BFzzVLF6HLC00hmPMBwHiQnns25 fVpE7n7qVXTM4xfIHnPsIkNvME12vyoaveRS2GLrhgFtuh4pWZJ9M9WAehGmAYPqNhPq GxJ3EXfmJp3wbfCdbiIQSk6/S5S7dCLQEQ1oKguFRuNHmZmDbTf4N9EF+5WhrNiMNJ9O NAtNphgxMMV+BxUK5PHiWtEsdSuvxwBvEaT0bfaMRKvP3pM1P9zwsB4ddk5TkWrnic1n 0Rzg== 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=uo1YFXXbXNALiXUbibThDjJ3Iv2svHhcYq0j+B9mVXs=; b=wMjv5AEc55iKvAJ6kOs+UbGYgs1XalW39Lo4vY2i3qQM3OBj6mPzRIr6YiF7Dyw9vp lawVixj73Y6ejcGEw8qy4bdUFiNC58dlD4YygSiQzaiu/c09xxGnxFKBeQjLF4AWtiS/ n7cyL1AeIHeonM65i786fiyQa9NN5chDIsF41pb+5L+d9ctvzcBE/NdRJc7vM/GZ8DAk HK1rcgiyxcAkk7ybpERIi8SXh2IhHCGgtUT/UVR2H/ToiLR1waJ/c9Vqig6I+Ao0Q0RC 97lqUiP6k8422v/RxSxZF65pmvzvGFxNoY8LIFirnY5q/QCbOrXIr1ZopLLaU0LTD2EK HlZA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b="ALTQUfJ/"; 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 d15si13854074ywb.64.2019.02.21.11.25.31 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 21 Feb 2019 11:25:31 -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="ALTQUfJ/"; 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]:37260 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwtyM-0007cl-Oz for patch@linaro.org; Thu, 21 Feb 2019 14:25:30 -0500 Received: from eggs.gnu.org ([209.51.188.92]:52296) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwtXu-00006N-KI 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 1gwtXp-0007TI-OY for qemu-devel@nongnu.org; Thu, 21 Feb 2019 13:58:10 -0500 Received: from mail-wr1-x443.google.com ([2a00:1450:4864:20::443]:46080) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gwtXp-0007Rl-Cu for qemu-devel@nongnu.org; Thu, 21 Feb 2019 13:58:05 -0500 Received: by mail-wr1-x443.google.com with SMTP id i16so23569598wrs.13 for ; Thu, 21 Feb 2019 10:58:05 -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=uo1YFXXbXNALiXUbibThDjJ3Iv2svHhcYq0j+B9mVXs=; b=ALTQUfJ/5GrnW/dNzkfv80DbowqzFR0mFmjdDOBt5OSXyOiJvRv6V7OOsha3bbY3mA yYxJNsSDEeg/RwkCFyt46v426gEgQGsi7jjfqJRN1L96ExVDv/M07lakc4o4hoVjeygV vMzSqSl08/af5ACuXGH+dhsiQD3vbbdDRYSJyRi5mD2uQ1I3we4/uRzuuTRdhd0TPrVr gaA0TQdtPxG1una6+Bg6p7ONTXqnmLmawfOXPhpsgUJfT6kEof1BDyod4EzPLCCVtVMK afiJBLzCxVHU8WjpQsm+/aWrzVNBeP0yVdhw5dvCXd7vO64Qr1cKOviQz8lkBTVkjUBf CNEA== 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=uo1YFXXbXNALiXUbibThDjJ3Iv2svHhcYq0j+B9mVXs=; b=TC0/7g4VbLIIu3VCEuobnzu5QWByfwJ3kO1U/sFqLFyQV8ElWuM9xYGSFDGfW+7+VR XXRnXam27+6DkNPA7c9VK0aQ/vlfBATJuipFFZ2T6w5L//o0LDpb+rX7BpfHk1TJqaHe fRd4ejjS2K4MSzJWOS/GHK+q/SnC6Q57f2X13X92vwipvdC4xpheP1769MzKXlRz8gEh 5IzEgUHfN05sFYjid923TOHDmDNdU64IH1pLTRKCPO/fExUrPuCpUL10D4/LM9/O/NhC 5WOH5GdwI5MPyAOIRqNkR2iK1sWoSQD8JQELmQWOHMdz90HOTteKmJHaphqWFq0YPTH9 sDag== X-Gm-Message-State: AHQUAuY4ZKgH28f9kpyQh6dLgU8xDLkfBDgXCRlc4BoEfrJ1zmRuqJuA RE5p3xLydMLw6fgZzxGXOrqTmOdu8MA= X-Received: by 2002:a5d:4147:: with SMTP id c7mr31384015wrq.235.1550775483659; Thu, 21 Feb 2019 10:58:03 -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.02 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 21 Feb 2019 10:58:02 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Date: Thu, 21 Feb 2019 18:57:35 +0000 Message-Id: <20190221185739.25362-18-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::443 Subject: [Qemu-devel] [PULL 17/21] hw/arm/musca: Add PPCs 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" Many of the devices on the Musca board live behind TrustZone Peripheral Protection Controllers (PPCs); add models of the PPCs, using a similar scheme to the MPS2 board models. This commit wires up the PPCs with "unimplemented device" stubs behind them in the correct places in the address map. Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson --- hw/arm/musca.c | 289 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 289 insertions(+) -- 2.20.1 diff --git a/hw/arm/musca.c b/hw/arm/musca.c index cc624c7d160..8774e0b87b7 100644 --- a/hw/arm/musca.c +++ b/hw/arm/musca.c @@ -27,8 +27,11 @@ #include "hw/arm/armsse.h" #include "hw/boards.h" #include "hw/core/split-irq.h" +#include "hw/misc/tz-ppc.h" +#include "hw/misc/unimp.h" #define MUSCA_NUMIRQ_MAX 96 +#define MUSCA_PPC_MAX 3 typedef enum MuscaType { MUSCA_A, @@ -48,6 +51,24 @@ typedef struct { ARMSSE sse; SplitIRQ cpu_irq_splitter[MUSCA_NUMIRQ_MAX]; + SplitIRQ sec_resp_splitter; + TZPPC ppc[MUSCA_PPC_MAX]; + MemoryRegion container; + UnimplementedDeviceState eflash[2]; + UnimplementedDeviceState qspi; + UnimplementedDeviceState mpc[5]; + UnimplementedDeviceState mhu[2]; + UnimplementedDeviceState pwm[3]; + UnimplementedDeviceState i2s; + UnimplementedDeviceState uart[2]; + UnimplementedDeviceState i2c[2]; + UnimplementedDeviceState spi; + UnimplementedDeviceState scc; + UnimplementedDeviceState timer; + UnimplementedDeviceState rtc; + UnimplementedDeviceState pvt; + UnimplementedDeviceState sdio; + UnimplementedDeviceState gpio; } MuscaMachineState; #define TYPE_MUSCA_MACHINE "musca" @@ -68,6 +89,94 @@ typedef struct { */ #define SYSCLK_FRQ 40000000 +/* + * Most of the devices in the Musca board sit behind Peripheral Protection + * Controllers. These data structures define the layout of which devices + * sit behind which PPCs. + * The devfn for each port is a function which creates, configures + * and initializes the device, returning the MemoryRegion which + * needs to be plugged into the downstream end of the PPC port. + */ +typedef MemoryRegion *MakeDevFn(MuscaMachineState *mms, void *opaque, + const char *name, hwaddr size); + +typedef struct PPCPortInfo { + const char *name; + MakeDevFn *devfn; + void *opaque; + hwaddr addr; + hwaddr size; +} PPCPortInfo; + +typedef struct PPCInfo { + const char *name; + PPCPortInfo ports[TZ_NUM_PORTS]; +} PPCInfo; + +static MemoryRegion *make_unimp_dev(MuscaMachineState *mms, + void *opaque, const char *name, hwaddr size) +{ + /* + * Initialize, configure and realize a TYPE_UNIMPLEMENTED_DEVICE, + * and return a pointer to its MemoryRegion. + */ + UnimplementedDeviceState *uds = opaque; + + sysbus_init_child_obj(OBJECT(mms), name, uds, + sizeof(UnimplementedDeviceState), + TYPE_UNIMPLEMENTED_DEVICE); + qdev_prop_set_string(DEVICE(uds), "name", name); + qdev_prop_set_uint64(DEVICE(uds), "size", size); + object_property_set_bool(OBJECT(uds), true, "realized", &error_fatal); + return sysbus_mmio_get_region(SYS_BUS_DEVICE(uds), 0); +} + +static MemoryRegion *make_musca_a_devs(MuscaMachineState *mms, void *opaque, + const char *name, hwaddr size) +{ + /* + * Create the container MemoryRegion for all the devices that live + * behind the Musca-A PPC's single port. These devices don't have a PPC + * port each, but we use the PPCPortInfo struct as a convenient way + * to describe them. Note that addresses here are relative to the base + * address of the PPC port region: 0x40100000, and devices appear both + * at the 0x4... NS region and the 0x5... S region. + */ + int i; + MemoryRegion *container = &mms->container; + + const PPCPortInfo devices[] = { + { "uart0", make_unimp_dev, &mms->uart[0], 0x1000, 0x1000 }, + { "uart1", make_unimp_dev, &mms->uart[1], 0x2000, 0x1000 }, + { "spi", make_unimp_dev, &mms->spi, 0x3000, 0x1000 }, + { "i2c0", make_unimp_dev, &mms->i2c[0], 0x4000, 0x1000 }, + { "i2c1", make_unimp_dev, &mms->i2c[1], 0x5000, 0x1000 }, + { "i2s", make_unimp_dev, &mms->i2s, 0x6000, 0x1000 }, + { "pwm0", make_unimp_dev, &mms->pwm[0], 0x7000, 0x1000 }, + { "rtc", make_unimp_dev, &mms->rtc, 0x8000, 0x1000 }, + { "qspi", make_unimp_dev, &mms->qspi, 0xa000, 0x1000 }, + { "timer", make_unimp_dev, &mms->timer, 0xb000, 0x1000 }, + { "scc", make_unimp_dev, &mms->scc, 0xc000, 0x1000 }, + { "pwm1", make_unimp_dev, &mms->pwm[1], 0xe000, 0x1000 }, + { "pwm2", make_unimp_dev, &mms->pwm[2], 0xf000, 0x1000 }, + { "gpio", make_unimp_dev, &mms->gpio, 0x10000, 0x1000 }, + { "mpc0", make_unimp_dev, &mms->mpc[0], 0x12000, 0x1000 }, + { "mpc1", make_unimp_dev, &mms->mpc[1], 0x13000, 0x1000 }, + }; + + memory_region_init(container, OBJECT(mms), "musca-device-container", size); + + for (i = 0; i < ARRAY_SIZE(devices); i++) { + const PPCPortInfo *pinfo = &devices[i]; + MemoryRegion *mr; + + mr = pinfo->devfn(mms, pinfo->opaque, pinfo->name, pinfo->size); + memory_region_add_subregion(container, pinfo->addr, mr); + } + + return &mms->container; +} + static void musca_init(MachineState *machine) { MuscaMachineState *mms = MUSCA_MACHINE(machine); @@ -75,6 +184,9 @@ static void musca_init(MachineState *machine) MachineClass *mc = MACHINE_GET_CLASS(machine); MemoryRegion *system_memory = get_system_memory(); DeviceState *ssedev; + DeviceState *dev_splitter; + const PPCInfo *ppcs; + int num_ppcs; int i; assert(mmc->num_irqs <= MUSCA_NUMIRQ_MAX); @@ -121,6 +233,183 @@ static void musca_init(MachineState *machine) "EXP_CPU1_IRQ", i)); } + /* + * The sec_resp_cfg output from the SSE-200 must be split into multiple + * lines, one for each of the PPCs we create here. + */ + object_initialize(&mms->sec_resp_splitter, sizeof(mms->sec_resp_splitter), + TYPE_SPLIT_IRQ); + object_property_add_child(OBJECT(machine), "sec-resp-splitter", + OBJECT(&mms->sec_resp_splitter), &error_fatal); + object_property_set_int(OBJECT(&mms->sec_resp_splitter), + ARRAY_SIZE(mms->ppc), "num-lines", &error_fatal); + object_property_set_bool(OBJECT(&mms->sec_resp_splitter), true, + "realized", &error_fatal); + dev_splitter = DEVICE(&mms->sec_resp_splitter); + qdev_connect_gpio_out_named(ssedev, "sec_resp_cfg", 0, + qdev_get_gpio_in(dev_splitter, 0)); + + /* + * Most of the devices in the board are behind Peripheral Protection + * Controllers. The required order for initializing things is: + * + initialize the PPC + * + initialize, configure and realize downstream devices + * + connect downstream device MemoryRegions to the PPC + * + realize the PPC + * + map the PPC's MemoryRegions to the places in the address map + * where the downstream devices should appear + * + wire up the PPC's control lines to the SSE object + * + * The PPC mapping differs for the -A and -B1 variants; the -A version + * is much simpler, using only a single port of a single PPC and putting + * all the devices behind that. + */ + const PPCInfo a_ppcs[] = { { + .name = "ahb_ppcexp0", + .ports = { + { "musca-devices", make_musca_a_devs, 0, 0x40100000, 0x100000 }, + }, + }, + }; + + /* + * Devices listed with an 0x4.. address appear in both the NS 0x4.. region + * and the 0x5.. S region. Devices listed with an 0x5.. address appear + * only in the S region. + */ + const PPCInfo b1_ppcs[] = { { + .name = "apb_ppcexp0", + .ports = { + { "eflash0", make_unimp_dev, &mms->eflash[0], + 0x52400000, 0x1000 }, + { "eflash1", make_unimp_dev, &mms->eflash[1], + 0x52500000, 0x1000 }, + { "qspi", make_unimp_dev, &mms->qspi, 0x42800000, 0x100000 }, + { "mpc0", make_unimp_dev, &mms->mpc[0], 0x52000000, 0x1000 }, + { "mpc1", make_unimp_dev, &mms->mpc[1], 0x52100000, 0x1000 }, + { "mpc2", make_unimp_dev, &mms->mpc[2], 0x52200000, 0x1000 }, + { "mpc3", make_unimp_dev, &mms->mpc[3], 0x52300000, 0x1000 }, + { "mhu0", make_unimp_dev, &mms->mhu[0], 0x42600000, 0x100000 }, + { "mhu1", make_unimp_dev, &mms->mhu[1], 0x42700000, 0x100000 }, + { }, /* port 9: unused */ + { }, /* port 10: unused */ + { }, /* port 11: unused */ + { }, /* port 12: unused */ + { }, /* port 13: unused */ + { "mpc4", make_unimp_dev, &mms->mpc[4], 0x52e00000, 0x1000 }, + }, + }, { + .name = "apb_ppcexp1", + .ports = { + { "pwm0", make_unimp_dev, &mms->pwm[0], 0x40101000, 0x1000 }, + { "pwm1", make_unimp_dev, &mms->pwm[1], 0x40102000, 0x1000 }, + { "pwm2", make_unimp_dev, &mms->pwm[2], 0x40103000, 0x1000 }, + { "i2s", make_unimp_dev, &mms->i2s, 0x40104000, 0x1000 }, + { "uart0", make_unimp_dev, &mms->uart[0], 0x40105000, 0x1000 }, + { "uart1", make_unimp_dev, &mms->uart[1], 0x40106000, 0x1000 }, + { "i2c0", make_unimp_dev, &mms->i2c[0], 0x40108000, 0x1000 }, + { "i2c1", make_unimp_dev, &mms->i2c[1], 0x40109000, 0x1000 }, + { "spi", make_unimp_dev, &mms->spi, 0x4010a000, 0x1000 }, + { "scc", make_unimp_dev, &mms->scc, 0x5010b000, 0x1000 }, + { "timer", make_unimp_dev, &mms->timer, 0x4010c000, 0x1000 }, + { "rtc", make_unimp_dev, &mms->rtc, 0x4010d000, 0x1000 }, + { "pvt", make_unimp_dev, &mms->pvt, 0x4010e000, 0x1000 }, + { "sdio", make_unimp_dev, &mms->sdio, 0x4010f000, 0x1000 }, + }, + }, { + .name = "ahb_ppcexp0", + .ports = { + { }, /* port 0: unused */ + { "gpio", make_unimp_dev, &mms->gpio, 0x41000000, 0x1000 }, + }, + }, + }; + + switch (mmc->type) { + case MUSCA_A: + ppcs = a_ppcs; + num_ppcs = ARRAY_SIZE(a_ppcs); + break; + case MUSCA_B1: + ppcs = b1_ppcs; + num_ppcs = ARRAY_SIZE(b1_ppcs); + break; + default: + g_assert_not_reached(); + } + assert(num_ppcs <= MUSCA_PPC_MAX); + + for (i = 0; i < num_ppcs; i++) { + const PPCInfo *ppcinfo = &ppcs[i]; + TZPPC *ppc = &mms->ppc[i]; + DeviceState *ppcdev; + int port; + char *gpioname; + + sysbus_init_child_obj(OBJECT(machine), ppcinfo->name, ppc, + sizeof(TZPPC), TYPE_TZ_PPC); + ppcdev = DEVICE(ppc); + + for (port = 0; port < TZ_NUM_PORTS; port++) { + const PPCPortInfo *pinfo = &ppcinfo->ports[port]; + MemoryRegion *mr; + char *portname; + + if (!pinfo->devfn) { + continue; + } + + mr = pinfo->devfn(mms, pinfo->opaque, pinfo->name, pinfo->size); + portname = g_strdup_printf("port[%d]", port); + object_property_set_link(OBJECT(ppc), OBJECT(mr), + portname, &error_fatal); + g_free(portname); + } + + object_property_set_bool(OBJECT(ppc), true, "realized", &error_fatal); + + for (port = 0; port < TZ_NUM_PORTS; port++) { + const PPCPortInfo *pinfo = &ppcinfo->ports[port]; + + if (!pinfo->devfn) { + continue; + } + sysbus_mmio_map(SYS_BUS_DEVICE(ppc), port, pinfo->addr); + + gpioname = g_strdup_printf("%s_nonsec", ppcinfo->name); + qdev_connect_gpio_out_named(ssedev, gpioname, port, + qdev_get_gpio_in_named(ppcdev, + "cfg_nonsec", + port)); + g_free(gpioname); + gpioname = g_strdup_printf("%s_ap", ppcinfo->name); + qdev_connect_gpio_out_named(ssedev, gpioname, port, + qdev_get_gpio_in_named(ppcdev, + "cfg_ap", port)); + g_free(gpioname); + } + + gpioname = g_strdup_printf("%s_irq_enable", ppcinfo->name); + qdev_connect_gpio_out_named(ssedev, gpioname, 0, + qdev_get_gpio_in_named(ppcdev, + "irq_enable", 0)); + g_free(gpioname); + gpioname = g_strdup_printf("%s_irq_clear", ppcinfo->name); + qdev_connect_gpio_out_named(ssedev, gpioname, 0, + qdev_get_gpio_in_named(ppcdev, + "irq_clear", 0)); + g_free(gpioname); + gpioname = g_strdup_printf("%s_irq_status", ppcinfo->name); + qdev_connect_gpio_out_named(ppcdev, "irq", 0, + qdev_get_gpio_in_named(ssedev, + gpioname, 0)); + g_free(gpioname); + + qdev_connect_gpio_out(dev_splitter, i, + qdev_get_gpio_in_named(ppcdev, + "cfg_sec_resp", 0)); + } + armv7m_load_kernel(ARM_CPU(first_cpu), machine->kernel_filename, 0x2000000); } From patchwork Thu Feb 21 18:57:36 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 158946 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp848195jaa; Thu, 21 Feb 2019 11:13:24 -0800 (PST) X-Google-Smtp-Source: AHgI3IZJ3pstnmCVzPzyr8E7YVVFR6bRDhlC8kL54GEkKiOqNQKIbNifxSDYo0UDY8g/AkcUdSgy X-Received: by 2002:a81:a192:: with SMTP id y140mr78872ywg.380.1550776404654; Thu, 21 Feb 2019 11:13:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550776404; cv=none; d=google.com; s=arc-20160816; b=TPhKh7ZIfAEFyyBZlG1aO+Wds3kk81XjLWROmat5V+s/F+uZKbPtlX9NFNPp5oH4+6 xijcoGaOqTc5DCDvY57v7BDD01rnr18X1cuLRWFt20GnxjzUZB4ZGRyiy5OKlhdhVdK7 ezx4yr0lwF0Z02ic/YYN60aX/GCzgxbFmVJM9F6GXDICTeLDKnN8til1NC31SrrNlOrA sJ5BJXOkhi9Ssds3AtkgncIkacQT8cpNDay/nC6cu+tWjmB+uNbmicYCbFVhdT76rl6t GBhUBT+ahAIoCn5JIKFd+cO4V8X3OC97ZdENOufCx+EFgZXK2MBgmAXuF3cKBMvAkZhj N+iQ== 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=lgt/0TfncrjZFHVUqY1F5/RCWOdn69qBp1Opyed3kCU=; b=UBn1uiQqqbUBQjJ0w4C8fCIa1WNHjmDUhBeQ9Onkd8zZUeUY9uAhedKoFLBX0PL9rm Pql6GBJm/4HKPIIGvXwrLWguWbQz5Q6gXKrGcrEbS9/IUPbgRimIDIQmSE2umm8RYhQe mXDLn40HZgVWZn7wXd6jdNjs+QNgyFlAdQwPGlF1OGhVxAeYEFjY1jlHnYT17aTnb1FN aUuLz9z+LauVY77OSd0ososENXVmpNDJvz/SC1VebfbJGWosuWLctagQABU6Y+Z9QOCC 5CJ8eCBj7RzjdKc9+bnioiS2i9+qMd3j7smxhRLL0O4VuqA1d8GgEYnZiMSA/O+AmXNv vC6g== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=zS3CWtCJ; 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 z128si13337586ywf.445.2019.02.21.11.13.24 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 21 Feb 2019 11:13:24 -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=zS3CWtCJ; 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]:37068 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwtme-0004E2-2S for patch@linaro.org; Thu, 21 Feb 2019 14:13:24 -0500 Received: from eggs.gnu.org ([209.51.188.92]:52291) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwtXu-00005v-9i for qemu-devel@nongnu.org; Thu, 21 Feb 2019 13:58:11 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gwtXq-0007Uq-SM for qemu-devel@nongnu.org; Thu, 21 Feb 2019 13:58:10 -0500 Received: from mail-wm1-x333.google.com ([2a00:1450:4864:20::333]:38584) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gwtXq-0007TD-Fs for qemu-devel@nongnu.org; Thu, 21 Feb 2019 13:58:06 -0500 Received: by mail-wm1-x333.google.com with SMTP id v26so10307435wmh.3 for ; Thu, 21 Feb 2019 10:58:06 -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=lgt/0TfncrjZFHVUqY1F5/RCWOdn69qBp1Opyed3kCU=; b=zS3CWtCJjPb2eac+vZYcEUXymGClddjTQuO+aq6MUuPVUAjCvOou1RGBSjCloQGC9S EnJzSOEvpdmAvimgpG+QsvSLXpF3oplLfZMHXkm4/oSEVjKm8KEIox3qan5R7aCHAkrZ EHFVvV+iYxVhFNqz6Ix82PBW2EdfFqwdcKo0LwXVjyNBOpiU/SJPxwl60Je5MQslKvby bGhwtkEuQXqyO/fscka/mqVqIumqaGqfOAtarZ6JSNP8IQyjHEKOXTAmk7cSmTFXa0AP 2ZQFpdmMa4d+Lb6lzwXyMi8U2IV5BfN+IuH2x5YqPcWqzMxn1lNdzoNZj6mnXjtU6tEV whUA== 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=lgt/0TfncrjZFHVUqY1F5/RCWOdn69qBp1Opyed3kCU=; b=R0wsFQXawdwyxBQlSvF6bfE2lopb0kk6MqUKzsxayEodkZ+paKVmaOw3svfL8mweYh ADGKPXvZvO2qyPGNUp77rWwooUeWh24r8Urut5/I8TBLzBvOMcGr5lfFLptZs/ZL/3kC uE4dDFbXUTQ+JrGb8FWQNWCeWnPzUVoqhjWvGEW/1ULIJMuQXD2iqPHes3PGqEr2/FNf RdRiSzqbqZ/PJDBT6/VzNc1FOQtuViKU13/NwvziLvM74Ih0fd34CoXKBTymld3v/BPv iwTLtgD8DIw20R6EzZiEd2AiHIXpc8qebJHL/DsluzYQA94+a0Sz0HVp963jL8S4K3U7 oAYg== X-Gm-Message-State: AHQUAuYvVFOsGROiZSJYy3B21jPTFtHGEOhNvaI1xbJbJ8n4UmXObF4D PKCL+gINJRY65z7owE5X4VxkqAlmerg= X-Received: by 2002:a1c:7610:: with SMTP id r16mr11333777wmc.139.1550775484814; Thu, 21 Feb 2019 10:58:04 -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.03 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 21 Feb 2019 10:58:04 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Date: Thu, 21 Feb 2019 18:57:36 +0000 Message-Id: <20190221185739.25362-19-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::333 Subject: [Qemu-devel] [PULL 18/21] hw/arm/musca: Add MPCs X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" The Musca board puts its SRAM and flash behind TrustZone Memory Protection Controllers (MPCs). Each MPC sits between the CPU and the RAM/flash, and also has a set of memory mapped control registers. Wire up the MPCs, and the memory behind them. For the moment we implement the flash as simple ROM, which cannot be reprogrammed by the guest. Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson --- hw/arm/musca.c | 155 ++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 147 insertions(+), 8 deletions(-) -- 2.20.1 diff --git a/hw/arm/musca.c b/hw/arm/musca.c index 8774e0b87b7..c4095c4579b 100644 --- a/hw/arm/musca.c +++ b/hw/arm/musca.c @@ -27,11 +27,15 @@ #include "hw/arm/armsse.h" #include "hw/boards.h" #include "hw/core/split-irq.h" +#include "hw/misc/tz-mpc.h" #include "hw/misc/tz-ppc.h" #include "hw/misc/unimp.h" #define MUSCA_NUMIRQ_MAX 96 #define MUSCA_PPC_MAX 3 +#define MUSCA_MPC_MAX 5 + +typedef struct MPCInfo MPCInfo; typedef enum MuscaType { MUSCA_A, @@ -44,19 +48,23 @@ typedef struct { uint32_t init_svtor; int sram_addr_width; int num_irqs; + const MPCInfo *mpc_info; + int num_mpcs; } MuscaMachineClass; typedef struct { MachineState parent; ARMSSE sse; + /* RAM and flash */ + MemoryRegion ram[MUSCA_MPC_MAX]; SplitIRQ cpu_irq_splitter[MUSCA_NUMIRQ_MAX]; SplitIRQ sec_resp_splitter; TZPPC ppc[MUSCA_PPC_MAX]; MemoryRegion container; UnimplementedDeviceState eflash[2]; UnimplementedDeviceState qspi; - UnimplementedDeviceState mpc[5]; + TZMPC mpc[MUSCA_MPC_MAX]; UnimplementedDeviceState mhu[2]; UnimplementedDeviceState pwm[3]; UnimplementedDeviceState i2s; @@ -69,6 +77,7 @@ typedef struct { UnimplementedDeviceState pvt; UnimplementedDeviceState sdio; UnimplementedDeviceState gpio; + UnimplementedDeviceState cryptoisland; } MuscaMachineState; #define TYPE_MUSCA_MACHINE "musca" @@ -131,6 +140,131 @@ static MemoryRegion *make_unimp_dev(MuscaMachineState *mms, return sysbus_mmio_get_region(SYS_BUS_DEVICE(uds), 0); } +typedef enum MPCInfoType { + MPC_RAM, + MPC_ROM, + MPC_CRYPTOISLAND, +} MPCInfoType; + +struct MPCInfo { + const char *name; + hwaddr addr; + hwaddr size; + MPCInfoType type; +}; + +/* Order of the MPCs here must match the order of the bits in SECMPCINTSTATUS */ +static const MPCInfo a_mpc_info[] = { { + .name = "qspi", + .type = MPC_ROM, + .addr = 0x00200000, + .size = 0x00800000, + }, { + .name = "sram", + .type = MPC_RAM, + .addr = 0x00000000, + .size = 0x00200000, + } +}; + +static const MPCInfo b1_mpc_info[] = { { + .name = "qspi", + .type = MPC_ROM, + .addr = 0x00000000, + .size = 0x02000000, + }, { + .name = "sram", + .type = MPC_RAM, + .addr = 0x0a400000, + .size = 0x00080000, + }, { + .name = "eflash0", + .type = MPC_ROM, + .addr = 0x0a000000, + .size = 0x00200000, + }, { + .name = "eflash1", + .type = MPC_ROM, + .addr = 0x0a200000, + .size = 0x00200000, + }, { + .name = "cryptoisland", + .type = MPC_CRYPTOISLAND, + .addr = 0x0a000000, + .size = 0x00200000, + } +}; + +static MemoryRegion *make_mpc(MuscaMachineState *mms, void *opaque, + const char *name, hwaddr size) +{ + /* + * Create an MPC and the RAM or flash behind it. + * MPC 0: eFlash 0 + * MPC 1: eFlash 1 + * MPC 2: SRAM + * MPC 3: QSPI flash + * MPC 4: CryptoIsland + * For now we implement the flash regions as ROM (ie not programmable) + * (with their control interface memory regions being unimplemented + * stubs behind the PPCs). + * The whole CryptoIsland region behind its MPC is an unimplemented stub. + */ + MuscaMachineClass *mmc = MUSCA_MACHINE_GET_CLASS(mms); + TZMPC *mpc = opaque; + int i = mpc - &mms->mpc[0]; + MemoryRegion *downstream; + MemoryRegion *upstream; + UnimplementedDeviceState *uds; + char *mpcname; + const MPCInfo *mpcinfo = mmc->mpc_info; + + mpcname = g_strdup_printf("%s-mpc", mpcinfo[i].name); + + switch (mpcinfo[i].type) { + case MPC_ROM: + downstream = &mms->ram[i]; + memory_region_init_rom(downstream, NULL, mpcinfo[i].name, + mpcinfo[i].size, &error_fatal); + break; + case MPC_RAM: + downstream = &mms->ram[i]; + memory_region_init_ram(downstream, NULL, mpcinfo[i].name, + mpcinfo[i].size, &error_fatal); + break; + case MPC_CRYPTOISLAND: + /* We don't implement the CryptoIsland yet */ + uds = &mms->cryptoisland; + sysbus_init_child_obj(OBJECT(mms), name, uds, + sizeof(UnimplementedDeviceState), + TYPE_UNIMPLEMENTED_DEVICE); + qdev_prop_set_string(DEVICE(uds), "name", mpcinfo[i].name); + qdev_prop_set_uint64(DEVICE(uds), "size", mpcinfo[i].size); + object_property_set_bool(OBJECT(uds), true, "realized", &error_fatal); + downstream = sysbus_mmio_get_region(SYS_BUS_DEVICE(uds), 0); + break; + default: + g_assert_not_reached(); + } + + sysbus_init_child_obj(OBJECT(mms), mpcname, mpc, sizeof(mms->mpc[0]), + TYPE_TZ_MPC); + object_property_set_link(OBJECT(mpc), OBJECT(downstream), + "downstream", &error_fatal); + object_property_set_bool(OBJECT(mpc), true, "realized", &error_fatal); + /* Map the upstream end of the MPC into system memory */ + upstream = sysbus_mmio_get_region(SYS_BUS_DEVICE(mpc), 1); + memory_region_add_subregion(get_system_memory(), mpcinfo[i].addr, upstream); + /* and connect its interrupt to the SSE-200 */ + qdev_connect_gpio_out_named(DEVICE(mpc), "irq", 0, + qdev_get_gpio_in_named(DEVICE(&mms->sse), + "mpcexp_status", i)); + + g_free(mpcname); + /* Return the register interface MR for our caller to map behind the PPC */ + return sysbus_mmio_get_region(SYS_BUS_DEVICE(mpc), 0); +} + static MemoryRegion *make_musca_a_devs(MuscaMachineState *mms, void *opaque, const char *name, hwaddr size) { @@ -160,8 +294,8 @@ static MemoryRegion *make_musca_a_devs(MuscaMachineState *mms, void *opaque, { "pwm1", make_unimp_dev, &mms->pwm[1], 0xe000, 0x1000 }, { "pwm2", make_unimp_dev, &mms->pwm[2], 0xf000, 0x1000 }, { "gpio", make_unimp_dev, &mms->gpio, 0x10000, 0x1000 }, - { "mpc0", make_unimp_dev, &mms->mpc[0], 0x12000, 0x1000 }, - { "mpc1", make_unimp_dev, &mms->mpc[1], 0x13000, 0x1000 }, + { "mpc0", make_mpc, &mms->mpc[0], 0x12000, 0x1000 }, + { "mpc1", make_mpc, &mms->mpc[1], 0x13000, 0x1000 }, }; memory_region_init(container, OBJECT(mms), "musca-device-container", size); @@ -190,6 +324,7 @@ static void musca_init(MachineState *machine) int i; assert(mmc->num_irqs <= MUSCA_NUMIRQ_MAX); + assert(mmc->num_mpcs <= MUSCA_MPC_MAX); if (strcmp(machine->cpu_type, mc->default_cpu_type) != 0) { error_report("This board can only be used with CPU %s", @@ -285,10 +420,10 @@ static void musca_init(MachineState *machine) { "eflash1", make_unimp_dev, &mms->eflash[1], 0x52500000, 0x1000 }, { "qspi", make_unimp_dev, &mms->qspi, 0x42800000, 0x100000 }, - { "mpc0", make_unimp_dev, &mms->mpc[0], 0x52000000, 0x1000 }, - { "mpc1", make_unimp_dev, &mms->mpc[1], 0x52100000, 0x1000 }, - { "mpc2", make_unimp_dev, &mms->mpc[2], 0x52200000, 0x1000 }, - { "mpc3", make_unimp_dev, &mms->mpc[3], 0x52300000, 0x1000 }, + { "mpc0", make_mpc, &mms->mpc[0], 0x52000000, 0x1000 }, + { "mpc1", make_mpc, &mms->mpc[1], 0x52100000, 0x1000 }, + { "mpc2", make_mpc, &mms->mpc[2], 0x52200000, 0x1000 }, + { "mpc3", make_mpc, &mms->mpc[3], 0x52300000, 0x1000 }, { "mhu0", make_unimp_dev, &mms->mhu[0], 0x42600000, 0x100000 }, { "mhu1", make_unimp_dev, &mms->mhu[1], 0x42700000, 0x100000 }, { }, /* port 9: unused */ @@ -296,7 +431,7 @@ static void musca_init(MachineState *machine) { }, /* port 11: unused */ { }, /* port 12: unused */ { }, /* port 13: unused */ - { "mpc4", make_unimp_dev, &mms->mpc[4], 0x52e00000, 0x1000 }, + { "mpc4", make_mpc, &mms->mpc[4], 0x52e00000, 0x1000 }, }, }, { .name = "apb_ppcexp1", @@ -434,6 +569,8 @@ static void musca_a_class_init(ObjectClass *oc, void *data) mmc->init_svtor = 0x10200000; mmc->sram_addr_width = 15; mmc->num_irqs = 64; + mmc->mpc_info = a_mpc_info; + mmc->num_mpcs = ARRAY_SIZE(a_mpc_info); } static void musca_b1_class_init(ObjectClass *oc, void *data) @@ -453,6 +590,8 @@ static void musca_b1_class_init(ObjectClass *oc, void *data) mmc->init_svtor = 0x10000000; mmc->sram_addr_width = 17; mmc->num_irqs = 96; + mmc->mpc_info = b1_mpc_info; + mmc->num_mpcs = ARRAY_SIZE(b1_mpc_info); } static const TypeInfo musca_info = { From patchwork Thu Feb 21 18:57:37 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 158944 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp847666jaa; Thu, 21 Feb 2019 11:12:53 -0800 (PST) X-Google-Smtp-Source: AHgI3IaVwCaKYx9nGhVRg4DK/uRy8Euj68BQJELMmJ11asS/7H/QwVrFYi/t6qRYQKBovPcJYDCY X-Received: by 2002:a25:cad1:: with SMTP id a200mr64132ybg.223.1550776373378; Thu, 21 Feb 2019 11:12:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550776373; cv=none; d=google.com; s=arc-20160816; b=r1c5P/oSqfDucJBDcY8s0rL8gluNTOgQDQaJeOv9nRDwd6C18T6cX74vWWHfPmFHRh qdmOvCXfREVMBv5yqkw4E3ydjIzs9Dtbsg8ozkxfUDhZMaNHo26URao4jqANiDJGtvti V4MjI4Qxk6nrjY7ZP7Bl6toB/3QZdEVqyGMOC5UItAF81vPCRoZWD3hD3UsTPlhE/ARI 3o84FDSKXp5k2S9Xi7hO4N4It0HLyOL/mGWxZQ9gEr93GmDhI74YbS1hHEKcPZWUGjGH wKFwSyOVfXVO7NrH7SWzbhH8ABxmdn/rOeaJF0M9RmSXR2vx72yzRIy4Ue/QKJpyj6j9 NW+g== 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=yjhsrKSxsIGixPKEGIdTSx/b3ttWRTc/Rj+eZtFIv6c=; b=pRB1Rg+W7NdZN2nnLki9BsDDFoM4iwqwXnosKdgzQnEUrOcJIklvwwOZaitEAhqc3s 6S8D0ki4LqD/1Ji5wtF1BOdUFE/yjl3S4oUsNtty45EtTD0jFpj+Kqfxj8g6SdGe8GiQ Jv2DbjzfaN8qzRNS20tYn/AZMIgbxS/JY8iCyfBI3nm/TN3hinyTUNi20VzJyqjxJuPq aLNNAkxs1pqFiOT4xIkMGBzQgkMX1yejayt6ikuOE4ztWeKegnYpMNjZwAlt73RSmPIg ypCbDbOWScPOq5t39DkqlunSe5ooaXJRJa02tyyhe2gXroZNEIgLakR79VOBKEhMborr /5Hg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=ruAdVKUe; 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 n128si6129497yba.358.2019.02.21.11.12.53 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 21 Feb 2019 11:12:53 -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=ruAdVKUe; 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]:37066 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwtm8-0003mS-Rs for patch@linaro.org; Thu, 21 Feb 2019 14:12:52 -0500 Received: from eggs.gnu.org ([209.51.188.92]:52280) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwtXt-00005j-W8 for qemu-devel@nongnu.org; Thu, 21 Feb 2019 13:58:10 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gwtXr-0007Vd-I6 for qemu-devel@nongnu.org; Thu, 21 Feb 2019 13:58:09 -0500 Received: from mail-wr1-x433.google.com ([2a00:1450:4864:20::433]:35736) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gwtXr-0007UV-9J for qemu-devel@nongnu.org; Thu, 21 Feb 2019 13:58:07 -0500 Received: by mail-wr1-x433.google.com with SMTP id t18so31879910wrx.2 for ; Thu, 21 Feb 2019 10:58:07 -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=yjhsrKSxsIGixPKEGIdTSx/b3ttWRTc/Rj+eZtFIv6c=; b=ruAdVKUednxw9QjSF/4jonZBja4yJ2ZwLjIQUHhRFsK3kQ9TNuaA5ef+dWjo9ofCtH wbOtZFrjzfWokm9c8V53VIg3FSXXLrfBjGFOdKNhQ79tjzVIPC39WE3hF0ly6yDsP70p uEDaEdK/wD+IRpDtDEUd7LGQEHtgunGmOSXTuxDAmuwaadeyUH0INE2M6UiohSJD4XIg l0CoAfBNDmDfwFxFmWJOG0kgcIyw9KBJa10mUsy6Mu0iT7fWPwJPXGvxssYXOh3RFOgw zF2xpivJd46AOIDK+pOVjvQgWX9EXxqG80A4Tas5D/viwcwyH91TZR1BQ9W7D5N98hDr LvCw== 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=yjhsrKSxsIGixPKEGIdTSx/b3ttWRTc/Rj+eZtFIv6c=; b=Co6zhWFOsXONL1Y/uMiPJWH3t9o7EluQ3OHnMWa8hQ65iDVc/hYBss9m7s4ApbggNP fSf9nBedFqpV4M/LS1/tujiWSA7EA4zOfhCP3b8FquQD4KOcVnxHHjnHCovau9IoV54H nvFB69epbW4desMycdNxNBFU8uB4eaXheDNSqqc2NMh1weB8wEtWLqX85N4atxNGG5Lq gsPkByROneLZM5ijDIl/ibHj/myO4HMEK7GprzZXDoNPHfGVLa5asWJfNzRGPd2n+/+s CyiiO/rPsSpoF+XJs44hIZG7zNZuKFF031BbliIwvdmUbkUIZXJ0C1bg9tfkIUtTYD2X k78Q== X-Gm-Message-State: AHQUAuZczVJ5ke7pu1MPljN5p63md+Sehby8Iu5fM5zKugOA/b52E2is bK6tN44qyWajSW7OUw99bwW/cP0nJRk= X-Received: by 2002:a5d:5681:: with SMTP id f1mr29623779wrv.95.1550775486165; Thu, 21 Feb 2019 10:58:06 -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.04 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 21 Feb 2019 10:58:05 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Date: Thu, 21 Feb 2019 18:57:37 +0000 Message-Id: <20190221185739.25362-20-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::433 Subject: [Qemu-devel] [PULL 19/21] hw/arm/musca: Wire up PL031 RTC 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" Wire up the PL031 RTC for the Musca board. Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson --- hw/arm/musca.c | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) -- 2.20.1 diff --git a/hw/arm/musca.c b/hw/arm/musca.c index c4095c4579b..378912b7385 100644 --- a/hw/arm/musca.c +++ b/hw/arm/musca.c @@ -30,6 +30,7 @@ #include "hw/misc/tz-mpc.h" #include "hw/misc/tz-ppc.h" #include "hw/misc/unimp.h" +#include "hw/timer/pl031.h" #define MUSCA_NUMIRQ_MAX 96 #define MUSCA_PPC_MAX 3 @@ -73,7 +74,7 @@ typedef struct { UnimplementedDeviceState spi; UnimplementedDeviceState scc; UnimplementedDeviceState timer; - UnimplementedDeviceState rtc; + PL031State rtc; UnimplementedDeviceState pvt; UnimplementedDeviceState sdio; UnimplementedDeviceState gpio; @@ -98,6 +99,14 @@ typedef struct { */ #define SYSCLK_FRQ 40000000 +static qemu_irq get_sse_irq_in(MuscaMachineState *mms, int irqno) +{ + /* Return a qemu_irq which will signal IRQ n to all CPUs in the SSE. */ + assert(irqno < MUSCA_NUMIRQ_MAX); + + return qdev_get_gpio_in(DEVICE(&mms->cpu_irq_splitter[irqno]), 0); +} + /* * Most of the devices in the Musca board sit behind Peripheral Protection * Controllers. These data structures define the layout of which devices @@ -265,6 +274,17 @@ static MemoryRegion *make_mpc(MuscaMachineState *mms, void *opaque, return sysbus_mmio_get_region(SYS_BUS_DEVICE(mpc), 0); } +static MemoryRegion *make_rtc(MuscaMachineState *mms, void *opaque, + const char *name, hwaddr size) +{ + PL031State *rtc = opaque; + + sysbus_init_child_obj(OBJECT(mms), name, rtc, sizeof(mms->rtc), TYPE_PL031); + object_property_set_bool(OBJECT(rtc), true, "realized", &error_fatal); + sysbus_connect_irq(SYS_BUS_DEVICE(rtc), 0, get_sse_irq_in(mms, 39)); + return sysbus_mmio_get_region(SYS_BUS_DEVICE(rtc), 0); +} + static MemoryRegion *make_musca_a_devs(MuscaMachineState *mms, void *opaque, const char *name, hwaddr size) { @@ -287,7 +307,7 @@ static MemoryRegion *make_musca_a_devs(MuscaMachineState *mms, void *opaque, { "i2c1", make_unimp_dev, &mms->i2c[1], 0x5000, 0x1000 }, { "i2s", make_unimp_dev, &mms->i2s, 0x6000, 0x1000 }, { "pwm0", make_unimp_dev, &mms->pwm[0], 0x7000, 0x1000 }, - { "rtc", make_unimp_dev, &mms->rtc, 0x8000, 0x1000 }, + { "rtc", make_rtc, &mms->rtc, 0x8000, 0x1000 }, { "qspi", make_unimp_dev, &mms->qspi, 0xa000, 0x1000 }, { "timer", make_unimp_dev, &mms->timer, 0xb000, 0x1000 }, { "scc", make_unimp_dev, &mms->scc, 0xc000, 0x1000 }, @@ -447,7 +467,7 @@ static void musca_init(MachineState *machine) { "spi", make_unimp_dev, &mms->spi, 0x4010a000, 0x1000 }, { "scc", make_unimp_dev, &mms->scc, 0x5010b000, 0x1000 }, { "timer", make_unimp_dev, &mms->timer, 0x4010c000, 0x1000 }, - { "rtc", make_unimp_dev, &mms->rtc, 0x4010d000, 0x1000 }, + { "rtc", make_rtc, &mms->rtc, 0x4010d000, 0x1000 }, { "pvt", make_unimp_dev, &mms->pvt, 0x4010e000, 0x1000 }, { "sdio", make_unimp_dev, &mms->sdio, 0x4010f000, 0x1000 }, }, From patchwork Thu Feb 21 18:57:38 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 158954 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp854554jaa; Thu, 21 Feb 2019 11:19:45 -0800 (PST) X-Google-Smtp-Source: AHgI3IYFXXWUHcX7TDZME6fQvSmU7rZnXenvz1WU63qB4moGVhxwCO27yFXLHITi/XTi+B6YaWVB X-Received: by 2002:a25:ddc7:: with SMTP id u190mr93290ybg.203.1550776785715; Thu, 21 Feb 2019 11:19:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550776785; cv=none; d=google.com; s=arc-20160816; b=qDqOLlNUT/jfeCC2mMChxxkBNNnqfF3vEcxfFviX2YnqP2/lBmszjoXxCg6ea8yqAp eFR41amAsFMIDMmekQydb3K+ONHLa2MyMQzgLvdfEKrHxk1j0s3EkQvYnxT7XZpvI4ms D+XqUPIjqZFjpHOHs46tGqz5yJfZj2rV/aFF2SdczwTuK+XQzEUejyjDXm4+nOlcAlKB hRLSO3EVQPZk7F9KI39h5S/U6ZKXmOcxtaSZRBpO/BHc6vIJjKpW9REfTxqR2fxR1Zi1 +FBehQGnp123Cu5DjljrDFqUoe7kMLZQXjDHx1KUsa9HIDsmeBpRA/9Exj6q8OWQnc9a JGaQ== 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=MceNF6rI0cHSh+l+WwLKDv+xTRefeJ/wcYYF2JEwE+8=; b=aUu+efKih/aqjutq8mUD3/4R/aMBDwNpNV/SlIDHKqtl886YTtT/Bbt3zXIOunHkDl U+j02myLn7JE+cwWssvStClc1ybfIjVTMFyTBuLroDvQQJ0xe0xdJxiA0yNKSl64Ocxd CSgR8OIQTZ+KUVJ7z+/JHg/nDp3UjgsGbnAzg5tc9gcIIUP7SOCy+yJr5D3IzAby4YYm n/ZrI7XaXjDhxh4D147ireI8hfY8Bt3QPDSd85vwNOJWBxrAwr7vAG7dZrfgZBkZopU7 rHlfq8cC385Tnn5u39Y7LZ91sHuHBKyn37Ue9Quga+5pUpp7Wx6MLCbg8WaU9MchIIPB dVnw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=qGSmbDyr; 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 u4si13781843ywb.107.2019.02.21.11.19.45 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 21 Feb 2019 11:19:45 -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=qGSmbDyr; 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]:37181 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwtsn-0001nD-6W for patch@linaro.org; Thu, 21 Feb 2019 14:19:45 -0500 Received: from eggs.gnu.org ([209.51.188.92]:52293) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwtXu-00006F-FU for qemu-devel@nongnu.org; Thu, 21 Feb 2019 13:58:11 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gwtXs-0007Wc-SJ for qemu-devel@nongnu.org; Thu, 21 Feb 2019 13:58:10 -0500 Received: from mail-wm1-x334.google.com ([2a00:1450:4864:20::334]:51170) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gwtXs-0007W1-Ja for qemu-devel@nongnu.org; Thu, 21 Feb 2019 13:58:08 -0500 Received: by mail-wm1-x334.google.com with SMTP id x7so10568189wmj.0 for ; Thu, 21 Feb 2019 10:58:08 -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=MceNF6rI0cHSh+l+WwLKDv+xTRefeJ/wcYYF2JEwE+8=; b=qGSmbDyrALlHfyrJQGO5bTn9BsrFbl2LyR9cYrPi7VDSoFQixd0r9CQwyLJoEeCcE0 4guktbU/A4KQIuJmfExSZVnD9xUZ/gMHYWn8duASA0QD67MNtjLS5DtnDa1hrEVF8Z3F LE6UQXiVVrX3F6rfK7QkssEK82wGO0KDSQs5lnK9Z63EGyGynj3zmxn2TCungcZhrY5l 4p0CICNWwAXgf8vpjnGjZhMc3+snT3VLaHrj0Ocnnytp1x5Du/TlcVh9H/RqoNndGq11 jWq3RHQ5NhjsZF7kf2xiTcyEsRZa8bxUVK7KhxZpE21YJOkmK0+ma/lsoBQxWV/5DZDE H50A== 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=MceNF6rI0cHSh+l+WwLKDv+xTRefeJ/wcYYF2JEwE+8=; b=LK3hCjnyTqB1ZuaA0YqbLMyJuM40LwlZ+cOSzWQjk5v0N6drYxSGsvU+fx1eVMEhXQ 1kPQpqnXSz0LjFbGmKjz5kRSeD2Qh5Q/apwFcRj0CODept+J1DbrHDF/APPArJ7WELHY XUjX8qvLG5APq7sMfaaKJ3ttyTiRF8G5VmATNOrbARgIge1BTU9i3VCLwTwdAWpMKOAk VuR+Wmff1Ov0k5EkZuOAyqnwgPg85sf1qXv6F0EQKaZ0dmzP6Zn7FtY7yyeSAlnkIi5e d/L3Wmnzj8OL3nnPDf8EGR+lDW3hiescJ5L7B8oDiDMazyouyXUmE4csYtcxsF4f3pE9 KSlg== X-Gm-Message-State: AHQUAub5LeIi5FO9n+eSUM7sfxIJ8Ookhiz9EPbUy3ttNkbwGmWENQEv nv6x8wVGycmBkHt/f/mWG40XkZFoKPI= X-Received: by 2002:a1c:a9d0:: with SMTP id s199mr9209wme.142.1550775487266; Thu, 21 Feb 2019 10:58:07 -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.06 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 21 Feb 2019 10:58:06 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Date: Thu, 21 Feb 2019 18:57:38 +0000 Message-Id: <20190221185739.25362-21-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::334 Subject: [Qemu-devel] [PULL 20/21] hw/arm/musca: Wire up PL011 UARTs 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" Wire up the two PL011 UARTs in the Musca board. Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson --- hw/arm/musca.c | 34 +++++++++++++++++++++++++++++----- 1 file changed, 29 insertions(+), 5 deletions(-) -- 2.20.1 diff --git a/hw/arm/musca.c b/hw/arm/musca.c index 378912b7385..23aff43f4bc 100644 --- a/hw/arm/musca.c +++ b/hw/arm/musca.c @@ -23,9 +23,11 @@ #include "qemu/error-report.h" #include "qapi/error.h" #include "exec/address-spaces.h" +#include "sysemu/sysemu.h" #include "hw/arm/arm.h" #include "hw/arm/armsse.h" #include "hw/boards.h" +#include "hw/char/pl011.h" #include "hw/core/split-irq.h" #include "hw/misc/tz-mpc.h" #include "hw/misc/tz-ppc.h" @@ -69,7 +71,7 @@ typedef struct { UnimplementedDeviceState mhu[2]; UnimplementedDeviceState pwm[3]; UnimplementedDeviceState i2s; - UnimplementedDeviceState uart[2]; + PL011State uart[2]; UnimplementedDeviceState i2c[2]; UnimplementedDeviceState spi; UnimplementedDeviceState scc; @@ -285,6 +287,28 @@ static MemoryRegion *make_rtc(MuscaMachineState *mms, void *opaque, return sysbus_mmio_get_region(SYS_BUS_DEVICE(rtc), 0); } +static MemoryRegion *make_uart(MuscaMachineState *mms, void *opaque, + const char *name, hwaddr size) +{ + PL011State *uart = opaque; + int i = uart - &mms->uart[0]; + int irqbase = 7 + i * 6; + SysBusDevice *s; + + sysbus_init_child_obj(OBJECT(mms), name, uart, sizeof(mms->uart[0]), + TYPE_PL011); + qdev_prop_set_chr(DEVICE(uart), "chardev", serial_hd(i)); + object_property_set_bool(OBJECT(uart), true, "realized", &error_fatal); + s = SYS_BUS_DEVICE(uart); + sysbus_connect_irq(s, 0, get_sse_irq_in(mms, irqbase + 5)); /* combined */ + sysbus_connect_irq(s, 1, get_sse_irq_in(mms, irqbase + 0)); /* RX */ + sysbus_connect_irq(s, 2, get_sse_irq_in(mms, irqbase + 1)); /* TX */ + sysbus_connect_irq(s, 3, get_sse_irq_in(mms, irqbase + 2)); /* RT */ + sysbus_connect_irq(s, 4, get_sse_irq_in(mms, irqbase + 3)); /* MS */ + sysbus_connect_irq(s, 5, get_sse_irq_in(mms, irqbase + 4)); /* E */ + return sysbus_mmio_get_region(SYS_BUS_DEVICE(uart), 0); +} + static MemoryRegion *make_musca_a_devs(MuscaMachineState *mms, void *opaque, const char *name, hwaddr size) { @@ -300,8 +324,8 @@ static MemoryRegion *make_musca_a_devs(MuscaMachineState *mms, void *opaque, MemoryRegion *container = &mms->container; const PPCPortInfo devices[] = { - { "uart0", make_unimp_dev, &mms->uart[0], 0x1000, 0x1000 }, - { "uart1", make_unimp_dev, &mms->uart[1], 0x2000, 0x1000 }, + { "uart0", make_uart, &mms->uart[0], 0x1000, 0x1000 }, + { "uart1", make_uart, &mms->uart[1], 0x2000, 0x1000 }, { "spi", make_unimp_dev, &mms->spi, 0x3000, 0x1000 }, { "i2c0", make_unimp_dev, &mms->i2c[0], 0x4000, 0x1000 }, { "i2c1", make_unimp_dev, &mms->i2c[1], 0x5000, 0x1000 }, @@ -460,8 +484,8 @@ static void musca_init(MachineState *machine) { "pwm1", make_unimp_dev, &mms->pwm[1], 0x40102000, 0x1000 }, { "pwm2", make_unimp_dev, &mms->pwm[2], 0x40103000, 0x1000 }, { "i2s", make_unimp_dev, &mms->i2s, 0x40104000, 0x1000 }, - { "uart0", make_unimp_dev, &mms->uart[0], 0x40105000, 0x1000 }, - { "uart1", make_unimp_dev, &mms->uart[1], 0x40106000, 0x1000 }, + { "uart0", make_uart, &mms->uart[0], 0x40105000, 0x1000 }, + { "uart1", make_uart, &mms->uart[1], 0x40106000, 0x1000 }, { "i2c0", make_unimp_dev, &mms->i2c[0], 0x40108000, 0x1000 }, { "i2c1", make_unimp_dev, &mms->i2c[1], 0x40109000, 0x1000 }, { "spi", make_unimp_dev, &mms->spi, 0x4010a000, 0x1000 }, 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: 158949 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp848689jaa; Thu, 21 Feb 2019 11:13:52 -0800 (PST) X-Google-Smtp-Source: AHgI3IZW08ypXv7dbpTT4YKr5rVZ8qI3YMiAo72/U1VyTVop3972DWKAXRhpTGcSbkW9EhMfQQLW X-Received: by 2002:a25:2e01:: with SMTP id u1mr67381ybu.241.1550776432595; Thu, 21 Feb 2019 11:13:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550776432; cv=none; d=google.com; s=arc-20160816; b=wkW1Pjq8WRHIFjBc8XURNyb1bkyYm8pBKkxPBXgNpGEdBp4s93LGqokjezrKlQmGYE DIX24pIewCneWqr8ED92ija5l1xNCKuZdr79zfBmRBPBk+iDxo5AbqzXzcATcx1olEej YpmjrdgnvKNf5Y+6T2tBHMaqqf9uJwWf3b7IHfdaPLBiFU3XH3yJUYwpA5MO7GTWmByZ CJsrhqE83dvG/XCnHKfF/5mseKhEOq0qXrP6ifpSw6RaZT4aQaT3ia885SssxdwR+YBr zCSQg7Cks9dv7ZNuoTgZFWTyzZRps4cnfBEdyVSDRN4E62P5BbjCwmTDa1L+k74sc4WK 4Raw== 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=b/CDe6+LrSLQgWuXOF/Ks8F6XdEn0wLjjvmfORAKBsk=; b=f+icJluumTGReeaj/VbkYzTayOeTf9R0dMdUWsjh0oe0m29hNT9xM0bY/1akK6gptR OP+Dc8SsVApbH0EW7U83FAcdeu0BzVwsSutCgQzD4FLM2eQk7ok5+0U2cSJ4lhVzw1Wm TCSUL2h5YqHqeNQRz7WamXzVsPRnHjXLojK6i6bwBLliUDuYNYZRXlGTq50O0SUIbn9S IZxs3W+mE2EuxK0svZJFFm+DzVIgnawFPQbESh+ZClTbhYDWRzyGxvciG+Jt3i9/pcMM wmKZc9X6c7fc95xAagw1ZWdQL5jUls+hXfeMiPPGl+z/gKXokP2nn3IApi0uUuqlc5HJ w8Jg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=u8LSmU2B; 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 o16si904314ybg.203.2019.02.21.11.13.52 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 21 Feb 2019 11:13:52 -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=u8LSmU2B; 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]:37082 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwtn6-0005Ry-2a for patch@linaro.org; Thu, 21 Feb 2019 14:13:52 -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-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+patch=linaro.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(-) -- 2.20.1 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);