From patchwork Thu Oct 24 16:26:34 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 11210191 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 294FC1515 for ; Thu, 24 Oct 2019 16:31:20 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id EECCC20663 for ; Thu, 24 Oct 2019 16:31:19 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="bhouM6n4" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org EECCC20663 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:47244 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNg18-00055n-EX for patchwork-qemu-devel@patchwork.kernel.org; Thu, 24 Oct 2019 12:31:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57659) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNfxV-0006ps-AZ for qemu-devel@nongnu.org; Thu, 24 Oct 2019 12:27:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iNfxS-0000eS-3N for qemu-devel@nongnu.org; Thu, 24 Oct 2019 12:27:32 -0400 Received: from mail-wr1-x434.google.com ([2a00:1450:4864:20::434]:41511) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iNfxR-0000dz-TF for qemu-devel@nongnu.org; Thu, 24 Oct 2019 12:27:30 -0400 Received: by mail-wr1-x434.google.com with SMTP id p4so26806620wrm.8 for ; Thu, 24 Oct 2019 09:27:29 -0700 (PDT) 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=eiQ4IS489mOFVCAyCVWUyEDk9Y5TrLD5uNTu22NV1VM=; b=bhouM6n4np/oeoSzuL4326RTK6Ue0NvudvGGjcz9DO3aFRfCy5pXgmwUYo66WfM2Vz /DnsmWd7L4wnz5uYQTc/htqKq2Vw43WrPa6afNtPk3uECmjxijpR1kPTfxiskTCVJZ1C qWSFJm41cCmJeRIiH95CiO0acODv/2JyHxT6vi638XDrPdSL+pTExeWAvcINujlz7ql8 vm/4KmFXahTnL2X5xeziYHCSkHEge7YR9fX7u75pYzUFD9tev2oSu4yvyR9uxCRvA2N4 Oy/OLG+CQ/zjYn3DglvSkt20XP1RDjt2ZuW4p00wYw3P8y7zNy3LJ8HMGZIQmkRZtAl6 l0vA== 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=eiQ4IS489mOFVCAyCVWUyEDk9Y5TrLD5uNTu22NV1VM=; b=ddBC4p3BC9b+Nq27GVameaFoN5CyJZmRGbolC6gLoS6B6JzMFTiJyBSxQLPFN+268s j9iwropIZ+ZE0xtc9ylXwM2pg/TQc+I0drzG3llwMJ+mFyOKpZL8va15xjCJ7hNp/lDq qbsrJWSR0dxhgk9HwOvkP9q1Ok7eH3nti5ojn9iHdy97W359OXfoJjrgZNMb0pZmbpR6 HSfaxVdw0QkGZ0x+ULyxHWqs9/lZLLYDNHe6ujp7uw0IMm/74viN6QlguAYMfDRGnVVS XAyPF2ZRFvBZ8VYEzg+AULFK3xINAqEmHI4ZOwq41wkcw7ThVnSN4pn8pAGeYNXo2f+g vA2A== X-Gm-Message-State: APjAAAUchNPzt/OBUe00rRsC90z/n3MxQxKXMEyiq5oVzACiLbujhjXy FZKuRyAsYXRnud9oTXtxONmVc3j+vjo= X-Google-Smtp-Source: APXvYqyVSAs3uaX6ljv7+34I7QX0usgjH1U2z8T6nrM4sy9fIFwkuUoZnp0BhoWaORxIFooYzvT6yQ== X-Received: by 2002:adf:e7c9:: with SMTP id e9mr4592574wrn.261.1571934448494; Thu, 24 Oct 2019 09:27:28 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id r27sm42606124wrc.55.2019.10.24.09.27.27 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Oct 2019 09:27:27 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 01/51] hw/gpio: Fix property accessors of the AST2600 GPIO 1.8V model Date: Thu, 24 Oct 2019 17:26:34 +0100 Message-Id: <20191024162724.31675-2-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191024162724.31675-1-peter.maydell@linaro.org> References: <20191024162724.31675-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 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" From: Cédric Le Goater The property names of AST2600 GPIO 1.8V model are one character bigger than the names of the other ASPEED GPIO model. Increase the string buffer size by one and be more strict on the expected pattern of the property name. This fixes the QOM test of the ast2600-evb machine under : Apple LLVM version 10.0.0 (clang-1000.10.44.4) Target: x86_64-apple-darwin17.7.0 Thread model: posix InstalledDir: /Library/Developer/CommandLineTools/usr/bin Cc: Rashmica Gupta Fixes: 36d737ee82b2 ("hw/gpio: Add in AST2600 specific implementation") Signed-off-by: Cédric Le Goater Message-id: 20191023130455.1347-2-clg@kaod.org Reviewed-by: Peter Maydell Signed-off-by: Peter Maydell --- hw/gpio/aspeed_gpio.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/hw/gpio/aspeed_gpio.c b/hw/gpio/aspeed_gpio.c index 196e47c2628..7acc5fa8e29 100644 --- a/hw/gpio/aspeed_gpio.c +++ b/hw/gpio/aspeed_gpio.c @@ -733,13 +733,13 @@ static void aspeed_gpio_get_pin(Object *obj, Visitor *v, const char *name, { int pin = 0xfff; bool level = true; - char group[3]; + char group[4]; AspeedGPIOState *s = ASPEED_GPIO(obj); int set_idx, group_idx = 0; if (sscanf(name, "gpio%2[A-Z]%1d", group, &pin) != 2) { /* 1.8V gpio */ - if (sscanf(name, "gpio%3s%1d", group, &pin) != 2) { + if (sscanf(name, "gpio%3[18A-E]%1d", group, &pin) != 2) { error_setg(errp, "%s: error reading %s", __func__, name); return; } @@ -760,7 +760,7 @@ static void aspeed_gpio_set_pin(Object *obj, Visitor *v, const char *name, Error *local_err = NULL; bool level; int pin = 0xfff; - char group[3]; + char group[4]; AspeedGPIOState *s = ASPEED_GPIO(obj); int set_idx, group_idx = 0; @@ -771,7 +771,7 @@ static void aspeed_gpio_set_pin(Object *obj, Visitor *v, const char *name, } if (sscanf(name, "gpio%2[A-Z]%1d", group, &pin) != 2) { /* 1.8V gpio */ - if (sscanf(name, "gpio%3s%1d", group, &pin) != 2) { + if (sscanf(name, "gpio%3[18A-E]%1d", group, &pin) != 2) { error_setg(errp, "%s: error reading %s", __func__, name); return; } From patchwork Thu Oct 24 16:26:35 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 11210333 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 003CF14ED for ; Thu, 24 Oct 2019 16:53:21 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id CA5B6205C9 for ; Thu, 24 Oct 2019 16:53:20 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="mRUJ6G1O" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CA5B6205C9 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:48048 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNgMR-00044g-ET for patchwork-qemu-devel@patchwork.kernel.org; Thu, 24 Oct 2019 12:53:19 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57682) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNfxW-0006sl-IK for qemu-devel@nongnu.org; Thu, 24 Oct 2019 12:27:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iNfxV-0000fb-7E for qemu-devel@nongnu.org; Thu, 24 Oct 2019 12:27:34 -0400 Received: from mail-wr1-x42d.google.com ([2a00:1450:4864:20::42d]:35307) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iNfxV-0000eb-14 for qemu-devel@nongnu.org; Thu, 24 Oct 2019 12:27:33 -0400 Received: by mail-wr1-x42d.google.com with SMTP id l10so26374632wrb.2 for ; Thu, 24 Oct 2019 09:27:30 -0700 (PDT) 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=xpXmKegf0IiPtTBa9NzxMTzRYFfOthHDRfOU4bFkq2w=; b=mRUJ6G1OwAb4K4PngOMgJO6xNhDs9M5DzPRo8KOd9tTEj084LuZICvhpG4zFfTWZ3Q tdXYqjjkcBglXGYKWLjkwJyPbBQtRUNZ9L5pX6eZKq/f5gMcNl+fhF9m2SN0Y9adXUK9 XnnxSqPs3ZKLEcUwoO9f0twsq9/rbu/UdQesZhwpLM+dkGD6k95rPiHrwrJQ9R8q78Ii ZP8STYM3XYjOrDLNknaWgQ2tRLDOSFnqzCZ1z2m8+lEaxZCoD9iYGBLy+A9Oe6r89oLR fc2PkXEfqjTwHlyCXOPIjIQYJsS5qBRvXtwmshhhE74IqQ1WnVpvznSKTMxh1rv9SRaw YgnQ== 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=xpXmKegf0IiPtTBa9NzxMTzRYFfOthHDRfOU4bFkq2w=; b=n8g51dWq4awKtByt6O+CR5C4oucBVIpW0/5rgQQPWP5denVxByu6zcyL+pklk2MJTW K40N89Q/i7MmbJr0lQdEWOW7zy1WQvlVy6Fv/Ny9WX8axoICeTbGd3hlyLkW0IClbz7K 2/V029ldWjqGvPDt0IFVSL4FPlBfetSNPvICK/jsms0fqeNC6rpizbpRggL23FyfG+20 vf143T31qnciSU3dYSxDm+gzZV1m+Nmg+6YARGQrrGbBf38okrjsamftJQ/vXcHTrbS9 gZBjxd2LgycEZzKMzNS1HTUTYWbItpkJ52NyyAPI2QTzTwU3RbkwpguupLweExEgnTlJ 6QQw== X-Gm-Message-State: APjAAAVSEUMJXPHtaQacNY3+ztp6L07KL5wYOMJ9iBq27ITs1uMJ6iKI YsMFimCKdQS0rQsGvdrVACks90WfOKo= X-Google-Smtp-Source: APXvYqxt/U09+FG7ZnOKobnnBEJp4XuNXpoIrlnAPRl++JGzxZC/0pdYZMGlj/Iioy3g9Vm27J2m/w== X-Received: by 2002:a5d:5591:: with SMTP id i17mr4466259wrv.151.1571934449696; Thu, 24 Oct 2019 09:27:29 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id r27sm42606124wrc.55.2019.10.24.09.27.28 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Oct 2019 09:27:28 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 02/51] aspeed: Add an AST2600 eval board Date: Thu, 24 Oct 2019 17:26:35 +0100 Message-Id: <20191024162724.31675-3-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191024162724.31675-1-peter.maydell@linaro.org> References: <20191024162724.31675-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::42d X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" From: Cédric Le Goater Signed-off-by: Cédric Le Goater Reviewed-by: Joel Stanley Message-id: 20191023130455.1347-3-clg@kaod.org Signed-off-by: Peter Maydell --- include/hw/arm/aspeed.h | 1 + hw/arm/aspeed.c | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/include/hw/arm/aspeed.h b/include/hw/arm/aspeed.h index 02073a6b4d6..f49bc7081e4 100644 --- a/include/hw/arm/aspeed.h +++ b/include/hw/arm/aspeed.h @@ -18,6 +18,7 @@ typedef struct AspeedBoardConfig { const char *desc; const char *soc_name; uint32_t hw_strap1; + uint32_t hw_strap2; const char *fmc_model; const char *spi_model; uint32_t num_cs; diff --git a/hw/arm/aspeed.c b/hw/arm/aspeed.c index 52993f84b46..028191ff36f 100644 --- a/hw/arm/aspeed.c +++ b/hw/arm/aspeed.c @@ -88,6 +88,10 @@ struct AspeedBoardState { /* Witherspoon hardware value: 0xF10AD216 (but use romulus definition) */ #define WITHERSPOON_BMC_HW_STRAP1 ROMULUS_BMC_HW_STRAP1 +/* AST2600 evb hardware value */ +#define AST2600_EVB_HW_STRAP1 0x000000C0 +#define AST2600_EVB_HW_STRAP2 0x00000003 + /* * The max ram region is for firmwares that scan the address space * with load/store to guess how much RAM the SoC has. @@ -187,6 +191,8 @@ static void aspeed_board_init(MachineState *machine, &error_abort); object_property_set_int(OBJECT(&bmc->soc), cfg->hw_strap1, "hw-strap1", &error_abort); + object_property_set_int(OBJECT(&bmc->soc), cfg->hw_strap2, "hw-strap2", + &error_abort); object_property_set_int(OBJECT(&bmc->soc), cfg->num_cs, "num-cs", &error_abort); object_property_set_int(OBJECT(&bmc->soc), machine->smp.cpus, "num-cpus", @@ -308,6 +314,12 @@ static void ast2500_evb_i2c_init(AspeedBoardState *bmc) i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 11), "ds1338", 0x32); } +static void ast2600_evb_i2c_init(AspeedBoardState *bmc) +{ + /* Start with some devices on our I2C busses */ + ast2500_evb_i2c_init(bmc); +} + static void romulus_bmc_i2c_init(AspeedBoardState *bmc) { AspeedSoCState *soc = &bmc->soc; @@ -455,6 +467,17 @@ static const AspeedBoardConfig aspeed_boards[] = { .num_cs = 2, .i2c_init = witherspoon_bmc_i2c_init, .ram = 512 * MiB, + }, { + .name = MACHINE_TYPE_NAME("ast2600-evb"), + .desc = "Aspeed AST2600 EVB (Cortex A7)", + .soc_name = "ast2600-a0", + .hw_strap1 = AST2600_EVB_HW_STRAP1, + .hw_strap2 = AST2600_EVB_HW_STRAP2, + .fmc_model = "w25q512jv", + .spi_model = "mx66u51235f", + .num_cs = 1, + .i2c_init = ast2600_evb_i2c_init, + .ram = 1 * GiB, }, }; From patchwork Thu Oct 24 16:26:36 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 11210335 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 597A314E5 for ; Thu, 24 Oct 2019 16:54:02 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 2F2C5205C9 for ; Thu, 24 Oct 2019 16:54:02 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="pjTaFwQY" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2F2C5205C9 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:48068 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNgN6-0005H9-Pb for patchwork-qemu-devel@patchwork.kernel.org; Thu, 24 Oct 2019 12:54:00 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57677) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNfxW-0006rQ-0z for qemu-devel@nongnu.org; Thu, 24 Oct 2019 12:27:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iNfxU-0000fH-J1 for qemu-devel@nongnu.org; Thu, 24 Oct 2019 12:27:33 -0400 Received: from mail-wr1-x443.google.com ([2a00:1450:4864:20::443]:38087) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iNfxU-0000f2-CM for qemu-devel@nongnu.org; Thu, 24 Oct 2019 12:27:32 -0400 Received: by mail-wr1-x443.google.com with SMTP id v9so15522516wrq.5 for ; Thu, 24 Oct 2019 09:27:32 -0700 (PDT) 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=cpjzzf90ZZlnCC/zG71N3R57DXjC6KFtdGEnCvJDP10=; b=pjTaFwQYEIMf7ZGqSvmwAJS07X0zGegcCruzfbYE7pDE5Qte0riKxkAkXV7joNR0VG RSzHPPslezWaqaXYGWGh8QTenovSa5zmyOUm2hAJXD/+xFOnONhlxRtzhU1WXBzbQzyM JwKcVdePQ1uVBssJ5tvRT/OHdJouTTnUOo4uJNfCC2p9947ZMk8cGh/GxtnVHTS9AEYE IpccfQcM3e8INUqShWf1UI77o5RXuZlpTF5TgEdad6DPhhLyJ9NgrP5pGXuyo9dG7x9B 0L+FSf6eCHdwOoQDVImx+UAwRUss6T0ySdCe62VNLSRhHkSh/hkOdriwwGx5hMOBdQNx 4pKw== 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=cpjzzf90ZZlnCC/zG71N3R57DXjC6KFtdGEnCvJDP10=; b=idUwRzbka6dqBRKtuUANrfA60qVuIjiOvZbbnGIYcpV+4pNC6L1cys23cmym8PSn9d 4IsKBdOptGpiSm16ly7uWIt9inPhxq5KlPrMJCb62/USB4xAJRzeYJf5XfKSgmyVpimB QpeKHMH25E6k9Jc/QdTqPuT2ykGs1cUSWYwwADhGR+xu7DZu7UVPz2aqvnt5Y8u8uFvx ittCbZDQVmW1GLQTG6G4GJ8pBZ1cIPNhjYHjAIsQkpzpDGHWS03xwLLxjfWlW0LrY5ve 9zOZN7nSPzU04+gD1rB7r8d4X+Bay6GHhY3JHlsOaHxLeeFunm7c6D9UtokHd9c+LFvl axrA== X-Gm-Message-State: APjAAAWTG19uUXuWoo3vaCONwAzbqavkBU6XZ/OKWD9+pjG9dYSJFDgV otJaZBYUdmKazt3tK5/38P9znJeHByU= X-Google-Smtp-Source: APXvYqyk2wUPgi3WTWa+gUA4PtsGJWkfa3EUC3g9gha46zwroGKaK9qch2Qp4e9n/HMvUz2tRJ18WQ== X-Received: by 2002:a5d:6a03:: with SMTP id m3mr4387221wru.90.1571934450942; Thu, 24 Oct 2019 09:27:30 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id r27sm42606124wrc.55.2019.10.24.09.27.29 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Oct 2019 09:27:30 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 03/51] target/arm: Split out rebuild_hflags_common Date: Thu, 24 Oct 2019 17:26:36 +0100 Message-Id: <20191024162724.31675-4-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191024162724.31675-1-peter.maydell@linaro.org> References: <20191024162724.31675-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 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson Create a function to compute the values of the TBFLAG_ANY bits that will be cached. For now, the env->hflags variable is not used, and the results are fed back to cpu_get_tb_cpu_state. Reviewed-by: Alex Bennée Signed-off-by: Richard Henderson Message-id: 20191023150057.25731-2-richard.henderson@linaro.org Signed-off-by: Peter Maydell --- target/arm/cpu.h | 29 ++++++++++++++++++----------- target/arm/helper.c | 26 +++++++++++++++++++------- 2 files changed, 37 insertions(+), 18 deletions(-) diff --git a/target/arm/cpu.h b/target/arm/cpu.h index 297ad5e47ad..ad79a6153bb 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -231,6 +231,9 @@ typedef struct CPUARMState { uint32_t pstate; uint32_t aarch64; /* 1 if CPU is in aarch64 state; inverse of PSTATE.nRW */ + /* Cached TBFLAGS state. See below for which bits are included. */ + uint32_t hflags; + /* Frequently accessed CPSR bits are stored separately for efficiency. This contains all the other bits. Use cpsr_{read,write} to access the whole CPSR. */ @@ -3140,15 +3143,18 @@ typedef ARMCPU ArchCPU; #include "exec/cpu-all.h" -/* Bit usage in the TB flags field: bit 31 indicates whether we are +/* + * Bit usage in the TB flags field: bit 31 indicates whether we are * in 32 or 64 bit mode. The meaning of the other bits depends on that. * We put flags which are shared between 32 and 64 bit mode at the top * of the word, and flags which apply to only one mode at the bottom. + * + * Unless otherwise noted, these bits are cached in env->hflags. */ FIELD(TBFLAG_ANY, AARCH64_STATE, 31, 1) FIELD(TBFLAG_ANY, MMUIDX, 28, 3) FIELD(TBFLAG_ANY, SS_ACTIVE, 27, 1) -FIELD(TBFLAG_ANY, PSTATE_SS, 26, 1) +FIELD(TBFLAG_ANY, PSTATE_SS, 26, 1) /* Not cached. */ /* Target EL if we take a floating-point-disabled exception */ FIELD(TBFLAG_ANY, FPEXC_EL, 24, 2) FIELD(TBFLAG_ANY, BE_DATA, 23, 1) @@ -3159,13 +3165,14 @@ FIELD(TBFLAG_ANY, BE_DATA, 23, 1) FIELD(TBFLAG_ANY, DEBUG_TARGET_EL, 21, 2) /* Bit usage when in AArch32 state: */ -FIELD(TBFLAG_A32, THUMB, 0, 1) -FIELD(TBFLAG_A32, VECLEN, 1, 3) -FIELD(TBFLAG_A32, VECSTRIDE, 4, 2) +FIELD(TBFLAG_A32, THUMB, 0, 1) /* Not cached. */ +FIELD(TBFLAG_A32, VECLEN, 1, 3) /* Not cached. */ +FIELD(TBFLAG_A32, VECSTRIDE, 4, 2) /* Not cached. */ /* * We store the bottom two bits of the CPAR as TB flags and handle * checks on the other bits at runtime. This shares the same bits as * VECSTRIDE, which is OK as no XScale CPU has VFP. + * Not cached, because VECLEN+VECSTRIDE are not cached. */ FIELD(TBFLAG_A32, XSCALE_CPAR, 4, 2) /* @@ -3174,15 +3181,15 @@ FIELD(TBFLAG_A32, XSCALE_CPAR, 4, 2) * the same thing as the current security state of the processor! */ FIELD(TBFLAG_A32, NS, 6, 1) -FIELD(TBFLAG_A32, VFPEN, 7, 1) -FIELD(TBFLAG_A32, CONDEXEC, 8, 8) +FIELD(TBFLAG_A32, VFPEN, 7, 1) /* Not cached. */ +FIELD(TBFLAG_A32, CONDEXEC, 8, 8) /* Not cached. */ FIELD(TBFLAG_A32, SCTLR_B, 16, 1) /* For M profile only, set if FPCCR.LSPACT is set */ -FIELD(TBFLAG_A32, LSPACT, 18, 1) +FIELD(TBFLAG_A32, LSPACT, 18, 1) /* Not cached. */ /* For M profile only, set if we must create a new FP context */ -FIELD(TBFLAG_A32, NEW_FP_CTXT_NEEDED, 19, 1) +FIELD(TBFLAG_A32, NEW_FP_CTXT_NEEDED, 19, 1) /* Not cached. */ /* For M profile only, set if FPCCR.S does not match current security state */ -FIELD(TBFLAG_A32, FPCCR_S_WRONG, 20, 1) +FIELD(TBFLAG_A32, FPCCR_S_WRONG, 20, 1) /* Not cached. */ /* For M profile only, Handler (ie not Thread) mode */ FIELD(TBFLAG_A32, HANDLER, 21, 1) /* For M profile only, whether we should generate stack-limit checks */ @@ -3194,7 +3201,7 @@ FIELD(TBFLAG_A64, SVEEXC_EL, 2, 2) FIELD(TBFLAG_A64, ZCR_LEN, 4, 4) FIELD(TBFLAG_A64, PAUTH_ACTIVE, 8, 1) FIELD(TBFLAG_A64, BT, 9, 1) -FIELD(TBFLAG_A64, BTYPE, 10, 2) +FIELD(TBFLAG_A64, BTYPE, 10, 2) /* Not cached. */ FIELD(TBFLAG_A64, TBID, 12, 2) static inline bool bswap_code(bool sctlr_b) diff --git a/target/arm/helper.c b/target/arm/helper.c index 0d9a2d2ab74..8829d91ae1d 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -11054,6 +11054,22 @@ ARMMMUIdx arm_stage1_mmu_idx(CPUARMState *env) } #endif +static uint32_t rebuild_hflags_common(CPUARMState *env, int fp_el, + ARMMMUIdx mmu_idx, uint32_t flags) +{ + flags = FIELD_DP32(flags, TBFLAG_ANY, FPEXC_EL, fp_el); + flags = FIELD_DP32(flags, TBFLAG_ANY, MMUIDX, + arm_to_core_mmu_idx(mmu_idx)); + + if (arm_cpu_data_is_big_endian(env)) { + flags = FIELD_DP32(flags, TBFLAG_ANY, BE_DATA, 1); + } + if (arm_singlestep_active(env)) { + flags = FIELD_DP32(flags, TBFLAG_ANY, SS_ACTIVE, 1); + } + return flags; +} + void cpu_get_tb_cpu_state(CPUARMState *env, target_ulong *pc, target_ulong *cs_base, uint32_t *pflags) { @@ -11145,7 +11161,7 @@ void cpu_get_tb_cpu_state(CPUARMState *env, target_ulong *pc, } } - flags = FIELD_DP32(flags, TBFLAG_ANY, MMUIDX, arm_to_core_mmu_idx(mmu_idx)); + flags = rebuild_hflags_common(env, fp_el, mmu_idx, flags); /* The SS_ACTIVE and PSTATE_SS bits correspond to the state machine * states defined in the ARM ARM for software singlestep: @@ -11153,9 +11169,9 @@ void cpu_get_tb_cpu_state(CPUARMState *env, target_ulong *pc, * 0 x Inactive (the TB flag for SS is always 0) * 1 0 Active-pending * 1 1 Active-not-pending + * SS_ACTIVE is set in hflags; PSTATE_SS is computed every TB. */ - if (arm_singlestep_active(env)) { - flags = FIELD_DP32(flags, TBFLAG_ANY, SS_ACTIVE, 1); + if (FIELD_EX32(flags, TBFLAG_ANY, SS_ACTIVE)) { if (is_a64(env)) { if (env->pstate & PSTATE_SS) { flags = FIELD_DP32(flags, TBFLAG_ANY, PSTATE_SS, 1); @@ -11166,10 +11182,6 @@ void cpu_get_tb_cpu_state(CPUARMState *env, target_ulong *pc, } } } - if (arm_cpu_data_is_big_endian(env)) { - flags = FIELD_DP32(flags, TBFLAG_ANY, BE_DATA, 1); - } - flags = FIELD_DP32(flags, TBFLAG_ANY, FPEXC_EL, fp_el); if (arm_v7m_is_handler_mode(env)) { flags = FIELD_DP32(flags, TBFLAG_A32, HANDLER, 1); From patchwork Thu Oct 24 16:26:37 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 11210195 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1D2D014ED for ; Thu, 24 Oct 2019 16:35:33 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E769521906 for ; Thu, 24 Oct 2019 16:35:32 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="dr9H6AZO" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E769521906 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:47408 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNg5D-000474-1M for patchwork-qemu-devel@patchwork.kernel.org; Thu, 24 Oct 2019 12:35:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57707) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNfxY-0006xn-PC for qemu-devel@nongnu.org; Thu, 24 Oct 2019 12:27:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iNfxX-0000ga-C6 for qemu-devel@nongnu.org; Thu, 24 Oct 2019 12:27:36 -0400 Received: from mail-wm1-x343.google.com ([2a00:1450:4864:20::343]:55221) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iNfxX-0000gC-4q for qemu-devel@nongnu.org; Thu, 24 Oct 2019 12:27:35 -0400 Received: by mail-wm1-x343.google.com with SMTP id g7so3535072wmk.4 for ; Thu, 24 Oct 2019 09:27:35 -0700 (PDT) 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=bYwTl3jw7Dzln0o9WYtKWCimWjsmaSgObx3Y/zWbSwc=; b=dr9H6AZOkBHB6ljOi+nH461RRs5U9Pe/21Xeopm5DhgSEFGUjfPz7p/vdKPM9fTOrG 3K4h/jT+F89ZzQ/tdBJ+K+QQ7t1fCdRt5mVslDCuUiiJ7XJge69YxQGj2MRGD0idHZSx QJe4vnoxDIvZxPtboKgw9QroU/pqRJrRSKfVpfn0LWuyM6EKtVR0K5VlUJs3QQ5X6lC1 jWiV7WwHCwfq5kIGQSLa9+dp8D9OZAfbcuIfseas8TwaP4tYaCJv5fCqD1JfVH3uhHha KoSKgQFsm3JWkPA7maEcuBF9/jQqKwZ6EWOGrmjUMMlbIvXl2WtwiP7nBQGlQi4xZ0+j ErWA== 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=bYwTl3jw7Dzln0o9WYtKWCimWjsmaSgObx3Y/zWbSwc=; b=bup9vY/cfd+UMKjDpiazuNeBDqFr3laL3IAs2FDj/rKcQgKsnumsgek1L7UK3aogHd dYTw4YN7p8XwNfqGgY8vJXrU3uIqkSpNhnsa2irbrtiQHIcLcHttZb+ZA/WiFinAMY5N TRetrsx/b36rrUI70mBRwws1OmW6a0Pt2RpPARd87AZhSfIbYUjFlKzamG+QmcReEvcL hncUxlypZtDxoCbMI/1NbU5YYwDq9lp9BqrDhV4QQJK6l6Gf2Y5OEglN/ZABvg1hX8np GxHIKrGTpzgFOHRxlFu355Us2H99KBeDPdYie/Ccene5NdAbMBNi1CbJ1/Qftf3dPxdA xsow== X-Gm-Message-State: APjAAAX4ISHTLXjNTJ0oFwmUUIIbFUKWQ/kZCYzrorhzAXsE2MplN5zO nmVQeNmABiNBzcfZTN3NpBmjGLNGi/Q= X-Google-Smtp-Source: APXvYqyc4iKotdz2c+oIUzHPAzfAURqBCHVu9xecQY+lXKt+9ijIqcyh2OeG0dyPn1QaQhoL1FSkXw== X-Received: by 2002:a05:600c:2318:: with SMTP id 24mr5519929wmo.146.1571934452572; Thu, 24 Oct 2019 09:27:32 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id r27sm42606124wrc.55.2019.10.24.09.27.31 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Oct 2019 09:27:31 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 04/51] target/arm: Split out rebuild_hflags_a64 Date: Thu, 24 Oct 2019 17:26:37 +0100 Message-Id: <20191024162724.31675-5-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191024162724.31675-1-peter.maydell@linaro.org> References: <20191024162724.31675-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 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson Create a function to compute the values of the TBFLAG_A64 bits that will be cached. For now, the env->hflags variable is not used, and the results are fed back to cpu_get_tb_cpu_state. Note that not all BTI related flags are cached, so we have to test the BTI feature twice -- once for those bits moved out to rebuild_hflags_a64 and once for those bits that remain in cpu_get_tb_cpu_state. Reviewed-by: Alex Bennée Signed-off-by: Richard Henderson Message-id: 20191023150057.25731-3-richard.henderson@linaro.org Signed-off-by: Peter Maydell --- target/arm/helper.c | 131 +++++++++++++++++++++++--------------------- 1 file changed, 69 insertions(+), 62 deletions(-) diff --git a/target/arm/helper.c b/target/arm/helper.c index 8829d91ae1d..69da04786e8 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -11070,6 +11070,71 @@ static uint32_t rebuild_hflags_common(CPUARMState *env, int fp_el, return flags; } +static uint32_t rebuild_hflags_a64(CPUARMState *env, int el, int fp_el, + ARMMMUIdx mmu_idx) +{ + ARMMMUIdx stage1 = stage_1_mmu_idx(mmu_idx); + ARMVAParameters p0 = aa64_va_parameters_both(env, 0, stage1); + uint32_t flags = 0; + uint64_t sctlr; + int tbii, tbid; + + flags = FIELD_DP32(flags, TBFLAG_ANY, AARCH64_STATE, 1); + + /* FIXME: ARMv8.1-VHE S2 translation regime. */ + if (regime_el(env, stage1) < 2) { + ARMVAParameters p1 = aa64_va_parameters_both(env, -1, stage1); + tbid = (p1.tbi << 1) | p0.tbi; + tbii = tbid & ~((p1.tbid << 1) | p0.tbid); + } else { + tbid = p0.tbi; + tbii = tbid & !p0.tbid; + } + + flags = FIELD_DP32(flags, TBFLAG_A64, TBII, tbii); + flags = FIELD_DP32(flags, TBFLAG_A64, TBID, tbid); + + if (cpu_isar_feature(aa64_sve, env_archcpu(env))) { + int sve_el = sve_exception_el(env, el); + uint32_t zcr_len; + + /* + * If SVE is disabled, but FP is enabled, + * then the effective len is 0. + */ + if (sve_el != 0 && fp_el == 0) { + zcr_len = 0; + } else { + zcr_len = sve_zcr_len_for_el(env, el); + } + flags = FIELD_DP32(flags, TBFLAG_A64, SVEEXC_EL, sve_el); + flags = FIELD_DP32(flags, TBFLAG_A64, ZCR_LEN, zcr_len); + } + + sctlr = arm_sctlr(env, el); + + if (cpu_isar_feature(aa64_pauth, env_archcpu(env))) { + /* + * In order to save space in flags, we record only whether + * pauth is "inactive", meaning all insns are implemented as + * a nop, or "active" when some action must be performed. + * The decision of which action to take is left to a helper. + */ + if (sctlr & (SCTLR_EnIA | SCTLR_EnIB | SCTLR_EnDA | SCTLR_EnDB)) { + flags = FIELD_DP32(flags, TBFLAG_A64, PAUTH_ACTIVE, 1); + } + } + + if (cpu_isar_feature(aa64_bti, env_archcpu(env))) { + /* Note that SCTLR_EL[23].BT == SCTLR_BT1. */ + if (sctlr & (el == 0 ? SCTLR_BT0 : SCTLR_BT1)) { + flags = FIELD_DP32(flags, TBFLAG_A64, BT, 1); + } + } + + return rebuild_hflags_common(env, fp_el, mmu_idx, flags); +} + void cpu_get_tb_cpu_state(CPUARMState *env, target_ulong *pc, target_ulong *cs_base, uint32_t *pflags) { @@ -11079,67 +11144,9 @@ void cpu_get_tb_cpu_state(CPUARMState *env, target_ulong *pc, uint32_t flags = 0; if (is_a64(env)) { - ARMCPU *cpu = env_archcpu(env); - uint64_t sctlr; - *pc = env->pc; - flags = FIELD_DP32(flags, TBFLAG_ANY, AARCH64_STATE, 1); - - /* Get control bits for tagged addresses. */ - { - ARMMMUIdx stage1 = stage_1_mmu_idx(mmu_idx); - ARMVAParameters p0 = aa64_va_parameters_both(env, 0, stage1); - int tbii, tbid; - - /* FIXME: ARMv8.1-VHE S2 translation regime. */ - if (regime_el(env, stage1) < 2) { - ARMVAParameters p1 = aa64_va_parameters_both(env, -1, stage1); - tbid = (p1.tbi << 1) | p0.tbi; - tbii = tbid & ~((p1.tbid << 1) | p0.tbid); - } else { - tbid = p0.tbi; - tbii = tbid & !p0.tbid; - } - - flags = FIELD_DP32(flags, TBFLAG_A64, TBII, tbii); - flags = FIELD_DP32(flags, TBFLAG_A64, TBID, tbid); - } - - if (cpu_isar_feature(aa64_sve, cpu)) { - int sve_el = sve_exception_el(env, current_el); - uint32_t zcr_len; - - /* If SVE is disabled, but FP is enabled, - * then the effective len is 0. - */ - if (sve_el != 0 && fp_el == 0) { - zcr_len = 0; - } else { - zcr_len = sve_zcr_len_for_el(env, current_el); - } - flags = FIELD_DP32(flags, TBFLAG_A64, SVEEXC_EL, sve_el); - flags = FIELD_DP32(flags, TBFLAG_A64, ZCR_LEN, zcr_len); - } - - sctlr = arm_sctlr(env, current_el); - - if (cpu_isar_feature(aa64_pauth, cpu)) { - /* - * In order to save space in flags, we record only whether - * pauth is "inactive", meaning all insns are implemented as - * a nop, or "active" when some action must be performed. - * The decision of which action to take is left to a helper. - */ - if (sctlr & (SCTLR_EnIA | SCTLR_EnIB | SCTLR_EnDA | SCTLR_EnDB)) { - flags = FIELD_DP32(flags, TBFLAG_A64, PAUTH_ACTIVE, 1); - } - } - - if (cpu_isar_feature(aa64_bti, cpu)) { - /* Note that SCTLR_EL[23].BT == SCTLR_BT1. */ - if (sctlr & (current_el == 0 ? SCTLR_BT0 : SCTLR_BT1)) { - flags = FIELD_DP32(flags, TBFLAG_A64, BT, 1); - } + flags = rebuild_hflags_a64(env, current_el, fp_el, mmu_idx); + if (cpu_isar_feature(aa64_bti, env_archcpu(env))) { flags = FIELD_DP32(flags, TBFLAG_A64, BTYPE, env->btype); } } else { @@ -11159,9 +11166,9 @@ void cpu_get_tb_cpu_state(CPUARMState *env, target_ulong *pc, flags = FIELD_DP32(flags, TBFLAG_A32, XSCALE_CPAR, env->cp15.c15_cpar); } - } - flags = rebuild_hflags_common(env, fp_el, mmu_idx, flags); + flags = rebuild_hflags_common(env, fp_el, mmu_idx, flags); + } /* The SS_ACTIVE and PSTATE_SS bits correspond to the state machine * states defined in the ARM ARM for software singlestep: From patchwork Thu Oct 24 16:26:38 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 11210337 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id EEFF714ED for ; Thu, 24 Oct 2019 16:55:06 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id C41B9205C9 for ; Thu, 24 Oct 2019 16:55:06 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="maqFf5oD" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C41B9205C9 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:48082 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNgO9-0006jE-9D for patchwork-qemu-devel@patchwork.kernel.org; Thu, 24 Oct 2019 12:55:05 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57709) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNfxY-0006xx-Sh for qemu-devel@nongnu.org; Thu, 24 Oct 2019 12:27:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iNfxX-0000gl-MK for qemu-devel@nongnu.org; Thu, 24 Oct 2019 12:27:36 -0400 Received: from mail-wr1-x441.google.com ([2a00:1450:4864:20::441]:32851) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iNfxX-0000gM-G4 for qemu-devel@nongnu.org; Thu, 24 Oct 2019 12:27:35 -0400 Received: by mail-wr1-x441.google.com with SMTP id s1so18033243wro.0 for ; Thu, 24 Oct 2019 09:27:35 -0700 (PDT) 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=KG6cHPR+km+P0qCVntKHolnh4Cws12yKWCSVL0d/8TE=; b=maqFf5oDHZ4o0OAhwnXBEl+RH9nScIIv5r8lEgPdzE5onANFU0egUkabpiczeWKAzj rNhMC+jKutez6LS2nJvYcO2cojsCuefFbQQcw89aQU2MD79zLJ98r/sBu+xGCewELLQS /GKinx1TKeaZVEa5yaWQwVv4iDtOeF5qKhTE90+kO3R2MaWEEEkOOPcMF/I+D5H2vb94 5X5YMukDjXkwPyvj5LHKxGhm6AlJBZJhUnWRbLusDLpp2HTfU9OtPc92xJj/+azwgE1Z VJ1x2h8EukwO0HLMswBS2K6jcFp6+AbLi5uhk/cDdyEZyo6gAixT+VehS7P2BrpKxjkL WCWA== 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=KG6cHPR+km+P0qCVntKHolnh4Cws12yKWCSVL0d/8TE=; b=JI24Xzbyb5b9hycDF3WtuKtTn/pksbIyEBBarlfEphpyW44Il8dnsFM81WP/NYFGOw G0b6zgDBkCqL6IjVFIp8T9Zft7Vett5Y+nktOVmJzPQkLDAH7gFeDPxEZrK52axf8jbK PO1cWtsFkJGj4TUayymVIMVw79qMrqVewv3ytneuyz0IZJE9EhVZwCBM16+z7rLWxSM+ auB0nwQtfV2uydXqekIE/vBJvhSGax2A83TWj1TPKBpwVGC3gqrLdPqltXo2nYwUW4Y1 PzTYPvG+uVXavSvECBoFj2Kw8toMCNTzZA4sqZq1MzrpK3Wc4DsBWVX1XkZ0HjhQ7gkq fmTQ== X-Gm-Message-State: APjAAAWHDUkuwUgWFSlWDCRe9uTCq/ILKE1Y23Tsb7YhlGPcq8Fu9BhO 7SYMREKCoczdhGWyBcIp8QTqA8OY1xg= X-Google-Smtp-Source: APXvYqxS/RBNkeVgmXBxP2szRRrxY2igJaHppI+addhh2X8c/7cp/m+hljlBzt3hCxlmBO+GhrTl9Q== X-Received: by 2002:adf:f5cc:: with SMTP id k12mr4555214wrp.65.1571934453633; Thu, 24 Oct 2019 09:27:33 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id r27sm42606124wrc.55.2019.10.24.09.27.32 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Oct 2019 09:27:32 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 05/51] target/arm: Split out rebuild_hflags_common_32 Date: Thu, 24 Oct 2019 17:26:38 +0100 Message-Id: <20191024162724.31675-6-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191024162724.31675-1-peter.maydell@linaro.org> References: <20191024162724.31675-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::441 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson Create a function to compute the values of the TBFLAG_A32 bits that will be cached, and are used by all profiles. Reviewed-by: Alex Bennée Signed-off-by: Richard Henderson Message-id: 20191023150057.25731-4-richard.henderson@linaro.org Signed-off-by: Peter Maydell --- target/arm/helper.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/target/arm/helper.c b/target/arm/helper.c index 69da04786e8..f05d0424745 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -11070,6 +11070,15 @@ static uint32_t rebuild_hflags_common(CPUARMState *env, int fp_el, return flags; } +static uint32_t rebuild_hflags_common_32(CPUARMState *env, int fp_el, + ARMMMUIdx mmu_idx, uint32_t flags) +{ + flags = FIELD_DP32(flags, TBFLAG_A32, SCTLR_B, arm_sctlr_b(env)); + flags = FIELD_DP32(flags, TBFLAG_A32, NS, !access_secure_reg(env)); + + return rebuild_hflags_common(env, fp_el, mmu_idx, flags); +} + static uint32_t rebuild_hflags_a64(CPUARMState *env, int el, int fp_el, ARMMMUIdx mmu_idx) { @@ -11141,7 +11150,7 @@ void cpu_get_tb_cpu_state(CPUARMState *env, target_ulong *pc, ARMMMUIdx mmu_idx = arm_mmu_idx(env); int current_el = arm_current_el(env); int fp_el = fp_exception_el(env, current_el); - uint32_t flags = 0; + uint32_t flags; if (is_a64(env)) { *pc = env->pc; @@ -11151,12 +11160,11 @@ void cpu_get_tb_cpu_state(CPUARMState *env, target_ulong *pc, } } else { *pc = env->regs[15]; + flags = rebuild_hflags_common_32(env, fp_el, mmu_idx, 0); flags = FIELD_DP32(flags, TBFLAG_A32, THUMB, env->thumb); flags = FIELD_DP32(flags, TBFLAG_A32, VECLEN, env->vfp.vec_len); flags = FIELD_DP32(flags, TBFLAG_A32, VECSTRIDE, env->vfp.vec_stride); flags = FIELD_DP32(flags, TBFLAG_A32, CONDEXEC, env->condexec_bits); - flags = FIELD_DP32(flags, TBFLAG_A32, SCTLR_B, arm_sctlr_b(env)); - flags = FIELD_DP32(flags, TBFLAG_A32, NS, !access_secure_reg(env)); if (env->vfp.xregs[ARM_VFP_FPEXC] & (1 << 30) || arm_el_is_aa64(env, 1) || arm_feature(env, ARM_FEATURE_M)) { flags = FIELD_DP32(flags, TBFLAG_A32, VFPEN, 1); @@ -11166,8 +11174,6 @@ void cpu_get_tb_cpu_state(CPUARMState *env, target_ulong *pc, flags = FIELD_DP32(flags, TBFLAG_A32, XSCALE_CPAR, env->cp15.c15_cpar); } - - flags = rebuild_hflags_common(env, fp_el, mmu_idx, flags); } /* The SS_ACTIVE and PSTATE_SS bits correspond to the state machine From patchwork Thu Oct 24 16:26: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: 11210341 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8AF1914E5 for ; Thu, 24 Oct 2019 16:56:00 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 61704205C9 for ; Thu, 24 Oct 2019 16:56:00 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="v+ohkY56" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 61704205C9 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:48102 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNgP1-0008OZ-9i for patchwork-qemu-devel@patchwork.kernel.org; Thu, 24 Oct 2019 12:55:59 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57720) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNfxZ-00070E-Tf for qemu-devel@nongnu.org; Thu, 24 Oct 2019 12:27:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iNfxY-0000h5-KY for qemu-devel@nongnu.org; Thu, 24 Oct 2019 12:27:37 -0400 Received: from mail-wr1-x444.google.com ([2a00:1450:4864:20::444]:35004) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iNfxY-0000gq-DO for qemu-devel@nongnu.org; Thu, 24 Oct 2019 12:27:36 -0400 Received: by mail-wr1-x444.google.com with SMTP id l10so26374937wrb.2 for ; Thu, 24 Oct 2019 09:27:36 -0700 (PDT) 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=W/AkGYR57m74r9FQYLQ/SGWlTLm2K1Vi5lkbHPvwzOg=; b=v+ohkY56joDiW3D5onCDcauK1bRNVXlblGyike9OipJKNxCByon+MLC49b9eHp5chS wCd/lrU2W8VLl06Q7UyoQAQ/MTxZC+2FdhxyYUGU6On6O9KTFRPy+6DTmhSugLg1XRaw O5T5cUcrW8EGizOgGRGAqZw9PDa/0B+jxsgAm89O52yJDPzHpSoyVVs3yQ1dypQMI3fO 9bs/Q9oOf+3gN74WFKmpfnmABYZmQQjEI/U5hUOZBIPG0iDYNs+hdctQPsloYeVgQOZM D0gsNct2QfJVmgKal6IZ8D8eKHuxjMcB2+M23V9rI7xybkqWlW6mS3IJ+osE4/ryZHLs mcDg== 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=W/AkGYR57m74r9FQYLQ/SGWlTLm2K1Vi5lkbHPvwzOg=; b=DMn7PbQ3EgZYTOLaMop9RJJa93YOfqdTRHx8Z8zsQSsHSQCJEKlCzHvNgiPoxBpw+p w+RtVPZevxrAd4VP8y2UzpMsbR/DlwUTQIs5tA8wG5h66CMhNFNT536/KZmx9/LFforM 7VbudEXx9vMPLDk0Ba7E2zHqz2WrU+FSx3ZawjKjtrirx6/ESnPcY3ktTdMhcbNpGOko lViX4DvHGtGG++Y1CC8Zj+mnnculGwd32Cgjq3VSaV0TXa1pyrBG7DII/VvdvzQw3Jg+ 7vbCBTkXfGFNoSN0SJAkm5etKGB92UXuFrEhxuePnD906gVhmx+/lOOjzwT2wKpUyAYo c5qg== X-Gm-Message-State: APjAAAXURX4gT+al6g5EASVugKG58i7sHfp06a7mmQJH0WBShtY89Z+6 hKTVK1IFDyHEk6RaVhucAxNh3lpfE7Y= X-Google-Smtp-Source: APXvYqyFYn4e1Hcnjaj1ySMwOOcdtnUj5vMymd1xHtnU2yWr+pMsGIzz0y0SRMIveGIKveNLd5jmuQ== X-Received: by 2002:adf:a157:: with SMTP id r23mr4447758wrr.51.1571934455075; Thu, 24 Oct 2019 09:27:35 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id r27sm42606124wrc.55.2019.10.24.09.27.33 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Oct 2019 09:27:34 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 06/51] target/arm: Split arm_cpu_data_is_big_endian Date: Thu, 24 Oct 2019 17:26:39 +0100 Message-Id: <20191024162724.31675-7-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191024162724.31675-1-peter.maydell@linaro.org> References: <20191024162724.31675-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::444 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson Set TBFLAG_ANY.BE_DATA in rebuild_hflags_common_32 and rebuild_hflags_a64 instead of rebuild_hflags_common, where we do not need to re-test is_a64() nor re-compute the various inputs. Reviewed-by: Alex Bennée Signed-off-by: Richard Henderson Message-id: 20191023150057.25731-5-richard.henderson@linaro.org Signed-off-by: Peter Maydell --- target/arm/cpu.h | 49 +++++++++++++++++++++++++++------------------ target/arm/helper.c | 16 +++++++++++---- 2 files changed, 42 insertions(+), 23 deletions(-) diff --git a/target/arm/cpu.h b/target/arm/cpu.h index ad79a6153bb..4d961474ce7 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -3108,33 +3108,44 @@ static inline uint64_t arm_sctlr(CPUARMState *env, int el) } } +static inline bool arm_cpu_data_is_big_endian_a32(CPUARMState *env, + bool sctlr_b) +{ +#ifdef CONFIG_USER_ONLY + /* + * In system mode, BE32 is modelled in line with the + * architecture (as word-invariant big-endianness), where loads + * and stores are done little endian but from addresses which + * are adjusted by XORing with the appropriate constant. So the + * endianness to use for the raw data access is not affected by + * SCTLR.B. + * In user mode, however, we model BE32 as byte-invariant + * big-endianness (because user-only code cannot tell the + * difference), and so we need to use a data access endianness + * that depends on SCTLR.B. + */ + if (sctlr_b) { + return true; + } +#endif + /* In 32bit endianness is determined by looking at CPSR's E bit */ + return env->uncached_cpsr & CPSR_E; +} + +static inline bool arm_cpu_data_is_big_endian_a64(int el, uint64_t sctlr) +{ + return sctlr & (el ? SCTLR_EE : SCTLR_E0E); +} /* Return true if the processor is in big-endian mode. */ static inline bool arm_cpu_data_is_big_endian(CPUARMState *env) { - /* In 32bit endianness is determined by looking at CPSR's E bit */ if (!is_a64(env)) { - return -#ifdef CONFIG_USER_ONLY - /* In system mode, BE32 is modelled in line with the - * architecture (as word-invariant big-endianness), where loads - * and stores are done little endian but from addresses which - * are adjusted by XORing with the appropriate constant. So the - * endianness to use for the raw data access is not affected by - * SCTLR.B. - * In user mode, however, we model BE32 as byte-invariant - * big-endianness (because user-only code cannot tell the - * difference), and so we need to use a data access endianness - * that depends on SCTLR.B. - */ - arm_sctlr_b(env) || -#endif - ((env->uncached_cpsr & CPSR_E) ? 1 : 0); + return arm_cpu_data_is_big_endian_a32(env, arm_sctlr_b(env)); } else { int cur_el = arm_current_el(env); uint64_t sctlr = arm_sctlr(env, cur_el); - - return (sctlr & (cur_el ? SCTLR_EE : SCTLR_E0E)) != 0; + return arm_cpu_data_is_big_endian_a64(cur_el, sctlr); } } diff --git a/target/arm/helper.c b/target/arm/helper.c index f05d0424745..4c65476d936 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -11061,9 +11061,6 @@ static uint32_t rebuild_hflags_common(CPUARMState *env, int fp_el, flags = FIELD_DP32(flags, TBFLAG_ANY, MMUIDX, arm_to_core_mmu_idx(mmu_idx)); - if (arm_cpu_data_is_big_endian(env)) { - flags = FIELD_DP32(flags, TBFLAG_ANY, BE_DATA, 1); - } if (arm_singlestep_active(env)) { flags = FIELD_DP32(flags, TBFLAG_ANY, SS_ACTIVE, 1); } @@ -11073,7 +11070,14 @@ static uint32_t rebuild_hflags_common(CPUARMState *env, int fp_el, static uint32_t rebuild_hflags_common_32(CPUARMState *env, int fp_el, ARMMMUIdx mmu_idx, uint32_t flags) { - flags = FIELD_DP32(flags, TBFLAG_A32, SCTLR_B, arm_sctlr_b(env)); + bool sctlr_b = arm_sctlr_b(env); + + if (sctlr_b) { + flags = FIELD_DP32(flags, TBFLAG_A32, SCTLR_B, 1); + } + if (arm_cpu_data_is_big_endian_a32(env, sctlr_b)) { + flags = FIELD_DP32(flags, TBFLAG_ANY, BE_DATA, 1); + } flags = FIELD_DP32(flags, TBFLAG_A32, NS, !access_secure_reg(env)); return rebuild_hflags_common(env, fp_el, mmu_idx, flags); @@ -11122,6 +11126,10 @@ static uint32_t rebuild_hflags_a64(CPUARMState *env, int el, int fp_el, sctlr = arm_sctlr(env, el); + if (arm_cpu_data_is_big_endian_a64(el, sctlr)) { + flags = FIELD_DP32(flags, TBFLAG_ANY, BE_DATA, 1); + } + if (cpu_isar_feature(aa64_pauth, env_archcpu(env))) { /* * In order to save space in flags, we record only whether From patchwork Thu Oct 24 16:26:40 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 11210353 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D24BB14E5 for ; Thu, 24 Oct 2019 16:57:54 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A887F205C9 for ; Thu, 24 Oct 2019 16:57:54 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="AGMo3tQg" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A887F205C9 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:48136 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNgQr-0003UO-4U for patchwork-qemu-devel@patchwork.kernel.org; Thu, 24 Oct 2019 12:57:53 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57783) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNfxg-0007A6-0C for qemu-devel@nongnu.org; Thu, 24 Oct 2019 12:27:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iNfxe-0000jA-L0 for qemu-devel@nongnu.org; Thu, 24 Oct 2019 12:27:43 -0400 Received: from mail-wm1-x341.google.com ([2a00:1450:4864:20::341]:35408) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iNfxe-0000iF-EB for qemu-devel@nongnu.org; Thu, 24 Oct 2019 12:27:42 -0400 Received: by mail-wm1-x341.google.com with SMTP id v6so3230483wmj.0 for ; Thu, 24 Oct 2019 09:27:42 -0700 (PDT) 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=Mk85QypYDHQ0fOkvmDB53SsHXryn+nYp39hNgWX4kxU=; b=AGMo3tQg390u3lF2ARQ4IHu8IMm0Oucb0mlsrmZGQJgUmJup0tAahvuUteScU3QzKy I7X9PQCuME9zG3AdqdaSwB1xXSNBbfyRN89AUmuQdHcgtGvRD2pupSIFleJP/nWowIc1 ZQPaEGZozLONvbxnPM7gfMgpmCKgY+tLYbLSkQX+MYOwaQQM/2fCqAWE4ttCzp/RWAFt boF1XMu0a8T7wRPKDwzzYSWwogeWZ2RJycCiT2ebuie1wHbFE22EqNslClh8GdYKxnYZ 69RBlITJG6Gz+4qQdeY/hOMKOi1mCNR5XNY+tLzmNK3eQlTdI75mWfjRKP6uaUx5qh5K cFww== 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=Mk85QypYDHQ0fOkvmDB53SsHXryn+nYp39hNgWX4kxU=; b=bQ+NiFe2/LkYQDIiBSD8Y3a7UrVbLKlmTGBqtF4qbVSF/25ynS6/v+BLXdheGufng3 ekvBcOOG5rafUQnsp7QZHUrLTjQUfc9r1xw4BHkaiBHRu1djAyqIOgc6AIOEa16A1jTe a9QUZ2UFh0jxSIpL+bPzwigegtqq/6FItPiEo19RhMK47B/abBZqO4KVbWkDTD3REguU X7EQgxZ/qpMxVW9UyHhE5751n60trdyxMGwoLo5VzZS2spMjsRZX/WayQcjLdiYrWHMT s7PFE+U1Dpd88m1q9hIflP1xxxP3GN6idgrwCNtsBfNkCNq2I/0Y5wz+dwhKYS6a2mOx tAoQ== X-Gm-Message-State: APjAAAWUuWrwjTcnRx27eAl1xELqWFRprkwlv2Y8ihVfJLHlAKLgkgYz jGPTw685iN2HWvDP1nR3M3bb0fQZ/ho= X-Google-Smtp-Source: APXvYqziKxTBvSMWvjoY5FSX3G0yJ1Qsc0ImpXX8ZUNmUMcC3E2lQjgAoT+M8hCqOh9Zj1yzUcHpKA== X-Received: by 2002:a1c:7719:: with SMTP id t25mr5530502wmi.56.1571934456271; Thu, 24 Oct 2019 09:27:36 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id r27sm42606124wrc.55.2019.10.24.09.27.35 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Oct 2019 09:27:35 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 07/51] target/arm: Split out rebuild_hflags_m32 Date: Thu, 24 Oct 2019 17:26:40 +0100 Message-Id: <20191024162724.31675-8-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191024162724.31675-1-peter.maydell@linaro.org> References: <20191024162724.31675-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::341 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson Create a function to compute the values of the TBFLAG_A32 bits that will be cached, and are used by M-profile. Reviewed-by: Alex Bennée Signed-off-by: Richard Henderson Message-id: 20191023150057.25731-6-richard.henderson@linaro.org Signed-off-by: Peter Maydell --- target/arm/helper.c | 45 ++++++++++++++++++++++++++++++--------------- 1 file changed, 30 insertions(+), 15 deletions(-) diff --git a/target/arm/helper.c b/target/arm/helper.c index 4c65476d936..d4303420daf 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -11083,6 +11083,29 @@ static uint32_t rebuild_hflags_common_32(CPUARMState *env, int fp_el, return rebuild_hflags_common(env, fp_el, mmu_idx, flags); } +static uint32_t rebuild_hflags_m32(CPUARMState *env, int fp_el, + ARMMMUIdx mmu_idx) +{ + uint32_t flags = 0; + + if (arm_v7m_is_handler_mode(env)) { + flags = FIELD_DP32(flags, TBFLAG_A32, HANDLER, 1); + } + + /* + * v8M always applies stack limit checks unless CCR.STKOFHFNMIGN + * is suppressing them because the requested execution priority + * is less than 0. + */ + if (arm_feature(env, ARM_FEATURE_V8) && + !((mmu_idx & ARM_MMU_IDX_M_NEGPRI) && + (env->v7m.ccr[env->v7m.secure] & R_V7M_CCR_STKOFHFNMIGN_MASK))) { + flags = FIELD_DP32(flags, TBFLAG_A32, STACKCHECK, 1); + } + + return rebuild_hflags_common_32(env, fp_el, mmu_idx, flags); +} + static uint32_t rebuild_hflags_a64(CPUARMState *env, int el, int fp_el, ARMMMUIdx mmu_idx) { @@ -11168,7 +11191,13 @@ void cpu_get_tb_cpu_state(CPUARMState *env, target_ulong *pc, } } else { *pc = env->regs[15]; - flags = rebuild_hflags_common_32(env, fp_el, mmu_idx, 0); + + if (arm_feature(env, ARM_FEATURE_M)) { + flags = rebuild_hflags_m32(env, fp_el, mmu_idx); + } else { + flags = rebuild_hflags_common_32(env, fp_el, mmu_idx, 0); + } + flags = FIELD_DP32(flags, TBFLAG_A32, THUMB, env->thumb); flags = FIELD_DP32(flags, TBFLAG_A32, VECLEN, env->vfp.vec_len); flags = FIELD_DP32(flags, TBFLAG_A32, VECSTRIDE, env->vfp.vec_stride); @@ -11204,20 +11233,6 @@ void cpu_get_tb_cpu_state(CPUARMState *env, target_ulong *pc, } } - if (arm_v7m_is_handler_mode(env)) { - flags = FIELD_DP32(flags, TBFLAG_A32, HANDLER, 1); - } - - /* v8M always applies stack limit checks unless CCR.STKOFHFNMIGN is - * suppressing them because the requested execution priority is less than 0. - */ - if (arm_feature(env, ARM_FEATURE_V8) && - arm_feature(env, ARM_FEATURE_M) && - !((mmu_idx & ARM_MMU_IDX_M_NEGPRI) && - (env->v7m.ccr[env->v7m.secure] & R_V7M_CCR_STKOFHFNMIGN_MASK))) { - flags = FIELD_DP32(flags, TBFLAG_A32, STACKCHECK, 1); - } - if (arm_feature(env, ARM_FEATURE_M_SECURITY) && FIELD_EX32(env->v7m.fpccr[M_REG_S], V7M_FPCCR, S) != env->v7m.secure) { flags = FIELD_DP32(flags, TBFLAG_A32, FPCCR_S_WRONG, 1); From patchwork Thu Oct 24 16:26:41 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 11210343 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7244114E5 for ; Thu, 24 Oct 2019 16:56:52 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 47B3320659 for ; Thu, 24 Oct 2019 16:56:52 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="USm43yl0" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 47B3320659 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:48123 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNgPq-0001cK-Pg for patchwork-qemu-devel@patchwork.kernel.org; Thu, 24 Oct 2019 12:56:50 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57744) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNfxd-00075g-R6 for qemu-devel@nongnu.org; Thu, 24 Oct 2019 12:27:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iNfxb-0000hx-IL for qemu-devel@nongnu.org; Thu, 24 Oct 2019 12:27:41 -0400 Received: from mail-wr1-x444.google.com ([2a00:1450:4864:20::444]:34391) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iNfxb-0000hi-Bv for qemu-devel@nongnu.org; Thu, 24 Oct 2019 12:27:39 -0400 Received: by mail-wr1-x444.google.com with SMTP id t16so21670601wrr.1 for ; Thu, 24 Oct 2019 09:27:39 -0700 (PDT) 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=0lnGCVKOKwt9P46Q56BLi+6ul/rpICS/xFMS4taRSZM=; b=USm43yl0wezCuR9HjbviXTDsNchFPo8hWLe8HV2XKY+xt7ZXiF+EU/r8BrPe57h3Mm deDCifSxU+3xZ+JHkzVIRvsyz20ciMWArSNauCZcychT75hIKRM1cpB5XvH9l47adVd+ 475pIAzLqYkG6U1X+Ch2hEOGQnZmmapQJV2svoqb4EW2mG3w+xKzyck90OC3b/wJQi59 vrPITMd5RTDkbMn802RAoxIdm2CghFHw+Zt4Cv5/e5XxomtxLrrf2585arWKh9IDyWiL MAQBWUyL0yLG6Cgci5kVDFjKpqNjhyp8JH21p6sbaowVcZKh4twFI4oCZ7nEiraT6gxL bGmQ== 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=0lnGCVKOKwt9P46Q56BLi+6ul/rpICS/xFMS4taRSZM=; b=ZkY+DPRxzxUEGlx7ImkKPqXz0c0xYbAMdueShIv3n0FZ2KKpPd31EGmaIPAcJRxUy6 L206GBehKtrWYvwe7UdghRMWf47c3eHnejAXPzJaPtFh+9/QycGbA/dj6t+9+dAIQkfL cFf3uCuEo01W7/rl1jhFzK92ymDXyDra19/XwfyOqC3VrNCs0rfM1UUfSjG0jG4034pa Vs7MB0z3VDJO1BHUHicLH50Oy6NJ60RhZIL4qwwQxLnJWCBSAlNJVINiALQwEHtzcub9 FYBpNZshoGDiEIuRxxji2nut8julPgHr1C2fJW9g9m/EZ6bCDEdVCCNWebakm49WqBBf T78A== X-Gm-Message-State: APjAAAWvOexPLrN9ycr3f3o/03FqJchbW7WYVomUaegEo6viQFKGSEm5 tGyKkAKciYSOf9/pXtrPomd6UTEHRS0= X-Google-Smtp-Source: APXvYqz+iZUbx0yMYMltTC8Pqf3WR58x8Oq1l/R0fVCeKecFs/8xez22gniQxx3ApkFSvi4Lj5YEuQ== X-Received: by 2002:adf:e850:: with SMTP id d16mr4456370wrn.251.1571934457275; Thu, 24 Oct 2019 09:27:37 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id r27sm42606124wrc.55.2019.10.24.09.27.36 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Oct 2019 09:27:36 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 08/51] target/arm: Reduce tests vs M-profile in cpu_get_tb_cpu_state Date: Thu, 24 Oct 2019 17:26:41 +0100 Message-Id: <20191024162724.31675-9-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191024162724.31675-1-peter.maydell@linaro.org> References: <20191024162724.31675-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::444 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson Hoist the computation of some TBFLAG_A32 bits that only apply to M-profile under a single test for ARM_FEATURE_M. Reviewed-by: Alex Bennée Signed-off-by: Richard Henderson Message-id: 20191023150057.25731-7-richard.henderson@linaro.org Signed-off-by: Peter Maydell --- target/arm/helper.c | 49 +++++++++++++++++++++------------------------ 1 file changed, 23 insertions(+), 26 deletions(-) diff --git a/target/arm/helper.c b/target/arm/helper.c index d4303420daf..296a4b2232c 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -11194,6 +11194,29 @@ void cpu_get_tb_cpu_state(CPUARMState *env, target_ulong *pc, if (arm_feature(env, ARM_FEATURE_M)) { flags = rebuild_hflags_m32(env, fp_el, mmu_idx); + + if (arm_feature(env, ARM_FEATURE_M_SECURITY) && + FIELD_EX32(env->v7m.fpccr[M_REG_S], V7M_FPCCR, S) + != env->v7m.secure) { + flags = FIELD_DP32(flags, TBFLAG_A32, FPCCR_S_WRONG, 1); + } + + if ((env->v7m.fpccr[env->v7m.secure] & R_V7M_FPCCR_ASPEN_MASK) && + (!(env->v7m.control[M_REG_S] & R_V7M_CONTROL_FPCA_MASK) || + (env->v7m.secure && + !(env->v7m.control[M_REG_S] & R_V7M_CONTROL_SFPA_MASK)))) { + /* + * ASPEN is set, but FPCA/SFPA indicate that there is no + * active FP context; we must create a new FP context before + * executing any FP insn. + */ + flags = FIELD_DP32(flags, TBFLAG_A32, NEW_FP_CTXT_NEEDED, 1); + } + + bool is_secure = env->v7m.fpccr[M_REG_S] & R_V7M_FPCCR_S_MASK; + if (env->v7m.fpccr[is_secure] & R_V7M_FPCCR_LSPACT_MASK) { + flags = FIELD_DP32(flags, TBFLAG_A32, LSPACT, 1); + } } else { flags = rebuild_hflags_common_32(env, fp_el, mmu_idx, 0); } @@ -11233,32 +11256,6 @@ void cpu_get_tb_cpu_state(CPUARMState *env, target_ulong *pc, } } - if (arm_feature(env, ARM_FEATURE_M_SECURITY) && - FIELD_EX32(env->v7m.fpccr[M_REG_S], V7M_FPCCR, S) != env->v7m.secure) { - flags = FIELD_DP32(flags, TBFLAG_A32, FPCCR_S_WRONG, 1); - } - - if (arm_feature(env, ARM_FEATURE_M) && - (env->v7m.fpccr[env->v7m.secure] & R_V7M_FPCCR_ASPEN_MASK) && - (!(env->v7m.control[M_REG_S] & R_V7M_CONTROL_FPCA_MASK) || - (env->v7m.secure && - !(env->v7m.control[M_REG_S] & R_V7M_CONTROL_SFPA_MASK)))) { - /* - * ASPEN is set, but FPCA/SFPA indicate that there is no active - * FP context; we must create a new FP context before executing - * any FP insn. - */ - flags = FIELD_DP32(flags, TBFLAG_A32, NEW_FP_CTXT_NEEDED, 1); - } - - if (arm_feature(env, ARM_FEATURE_M)) { - bool is_secure = env->v7m.fpccr[M_REG_S] & R_V7M_FPCCR_S_MASK; - - if (env->v7m.fpccr[is_secure] & R_V7M_FPCCR_LSPACT_MASK) { - flags = FIELD_DP32(flags, TBFLAG_A32, LSPACT, 1); - } - } - if (!arm_feature(env, ARM_FEATURE_M)) { int target_el = arm_debug_target_el(env); From patchwork Thu Oct 24 16:26:42 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 11210359 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 50C9114E5 for ; Thu, 24 Oct 2019 16:59:43 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 27102205C9 for ; Thu, 24 Oct 2019 16:59:43 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="yCg1sKpr" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 27102205C9 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:48176 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNgSc-0006mo-5Z for patchwork-qemu-devel@patchwork.kernel.org; Thu, 24 Oct 2019 12:59:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57749) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNfxe-00076g-7e for qemu-devel@nongnu.org; Thu, 24 Oct 2019 12:27:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iNfxc-0000i9-3C for qemu-devel@nongnu.org; Thu, 24 Oct 2019 12:27:42 -0400 Received: from mail-wm1-x330.google.com ([2a00:1450:4864:20::330]:52274) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iNfxb-0000hr-TK for qemu-devel@nongnu.org; Thu, 24 Oct 2019 12:27:40 -0400 Received: by mail-wm1-x330.google.com with SMTP id p21so2099009wmg.2 for ; Thu, 24 Oct 2019 09:27:39 -0700 (PDT) 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=HFxRD9cQcWniuYeniFsehWwir7VzmPqYaumnJ4Y7pcY=; b=yCg1sKprtJlTwGko3Fgo0RZR29KzFptM/pmjw6ikqFGl3q+0y6wha6Qzp1D2U+zqYJ UKGzBz47sgJv6/kMh0TCuwyTWl31hmmq1I7jbG1FNiSsjAzwB61ai8R+nKb8pZ6kOVmn V+5WQY6ODMVzAdqKbLfx7VxottE7EJXXLTZx5yUHWYqoeT0TsFdvkrHGegmc8rkCY6v3 qIWLWDphHz+viE5NZPSlbuhB/9vO9NqV59EanvWIJho0217hdZGwBijnX6iPR/zf+TrF pwFnzqXBis0NuTMmH0mwHPKpI2vdzNXvZs/MEzvR178gUw8hduUmUwpsNtoIy+DKYtrm dymg== 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=HFxRD9cQcWniuYeniFsehWwir7VzmPqYaumnJ4Y7pcY=; b=p4RLNrLYSwluilE+uGRK5Sn4CNoYOFtwNlbmBoZ1ThC+XJF347lFxIt0/xo4MLnUSF Xj8utHLPUNaDXeLcV6nO1aLdVPcHuiGrW4qS+7jHv+CxlJiqaxBox8qnZmVUZ/WLJIVH U2qSguDD7NVJ+ggis2xQGpKmzo8Dlokx5ZWr0wtsB/Xhku7Zj2GCtWXbkj0CoIYhXSgU u9DX4wknQnN6GsbVqL/YWCsx8p+vwSZuXsmw7XghoIbCINdrvwR8J5Xxl2qYH/LnC6Ax NZtjBZAm8ek/tu78GlvgyBzJrOt4UOCyZSrTnyv2Pv1Ii591qemmKqU3yNmG+1iTItC3 BmmQ== X-Gm-Message-State: APjAAAXht3tSkkbeBl9eTg9dayVJ5Ci+H8qE03OWbe1A/6M4h0wSeQuI Rmty8Lairlp5Qasql55TvtSL/lgOae4= X-Google-Smtp-Source: APXvYqxay4Pvu0+RYXxrldDU9oOSq7uBGCAPpA8EXHaAMLcLTSfZPNDdfm1BYQY8eRJJyUru6D4NEQ== X-Received: by 2002:a1c:1b07:: with SMTP id b7mr5674323wmb.111.1571934458406; Thu, 24 Oct 2019 09:27:38 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id r27sm42606124wrc.55.2019.10.24.09.27.37 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Oct 2019 09:27:37 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 09/51] target/arm: Split out rebuild_hflags_a32 Date: Thu, 24 Oct 2019 17:26:42 +0100 Message-Id: <20191024162724.31675-10-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191024162724.31675-1-peter.maydell@linaro.org> References: <20191024162724.31675-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::330 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson Currently a trivial wrapper for rebuild_hflags_common_32. Reviewed-by: Alex Bennée Signed-off-by: Richard Henderson Message-id: 20191023150057.25731-8-richard.henderson@linaro.org Signed-off-by: Peter Maydell --- target/arm/helper.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/target/arm/helper.c b/target/arm/helper.c index 296a4b2232c..d1cd54cc931 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -11106,6 +11106,12 @@ static uint32_t rebuild_hflags_m32(CPUARMState *env, int fp_el, return rebuild_hflags_common_32(env, fp_el, mmu_idx, flags); } +static uint32_t rebuild_hflags_a32(CPUARMState *env, int fp_el, + ARMMMUIdx mmu_idx) +{ + return rebuild_hflags_common_32(env, fp_el, mmu_idx, 0); +} + static uint32_t rebuild_hflags_a64(CPUARMState *env, int el, int fp_el, ARMMMUIdx mmu_idx) { @@ -11218,7 +11224,7 @@ void cpu_get_tb_cpu_state(CPUARMState *env, target_ulong *pc, flags = FIELD_DP32(flags, TBFLAG_A32, LSPACT, 1); } } else { - flags = rebuild_hflags_common_32(env, fp_el, mmu_idx, 0); + flags = rebuild_hflags_a32(env, fp_el, mmu_idx); } flags = FIELD_DP32(flags, TBFLAG_A32, THUMB, env->thumb); From patchwork Thu Oct 24 16:26:43 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 11210217 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 368B714ED for ; Thu, 24 Oct 2019 16:38:48 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 0B47721D81 for ; Thu, 24 Oct 2019 16:38:48 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="r1LiLYvL" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0B47721D81 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:47556 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNg8M-0001ch-8L for patchwork-qemu-devel@patchwork.kernel.org; Thu, 24 Oct 2019 12:38:46 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57766) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNfxf-00078S-0Y for qemu-devel@nongnu.org; Thu, 24 Oct 2019 12:27:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iNfxd-0000ij-RM for qemu-devel@nongnu.org; Thu, 24 Oct 2019 12:27:42 -0400 Received: from mail-wm1-x342.google.com ([2a00:1450:4864:20::342]:35409) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iNfxd-0000iP-L4 for qemu-devel@nongnu.org; Thu, 24 Oct 2019 12:27:41 -0400 Received: by mail-wm1-x342.google.com with SMTP id v6so3230506wmj.0 for ; Thu, 24 Oct 2019 09:27:41 -0700 (PDT) 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=HhJomiYWFoyGiQnBnfLm1DrjhXgk0FPd/bxO+44fxEo=; b=r1LiLYvL9/JKnkM0wrN8hqzHjWmnLUecPjgIlAub3XQ7/1G3U7cfIimsaJW7iv6Zd0 eH4W3hct1VcH3t2Yi09DXHffkliUKwCaYhRY0doErRULRMXOyMWL22GFRUYBRZo6fB7I tnqWjp19Bebbs6G49Qpy6MuCU35g99lQuLI0L+9RQ8HfHacZrilOiIkrsGFhelmdGOV6 tZLMXkPj8aQaKPGW1cvogRda8IvLigwBXtPewyn19q8Cms6Vdr7iDDTX8EdTxvx5Uknn HIYydQ8wXoaGjjEioqW6oGNKPcfpzoBLmTdOfAziVjSOyOfIrKEMOUpHH8tHA1xjwhrw naOA== 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=HhJomiYWFoyGiQnBnfLm1DrjhXgk0FPd/bxO+44fxEo=; b=d4QnKfyHU8GoK2mjjtaV7JOCD6/ekpKeFuk0FWnFJcYQf9sUsjwgKrXY+IqAaU0ux5 S6yyBsNOqH7mYdqE3t7GdqX2NYC9U77mm6k9m6GUwjUs7XNJlv1b7HFG14HkwVxBXYc4 DwCT2L7+0xMr0Ep09OGG42mMGHTb0aqQBbjQbK3jib9YN33I+IhuBk/Z3ywOSXWtT1Aw JxC9/xeeGZuOi7Rzq+Pk1VwGdjubXTM2rMgcyyTepKmcarMrlwA29PHuXItNGjRgA/da 54SvHHHnTvbLDMZLLqN5sz+YGpev5ayKGkrhg1CHBap2naXvZIoXyH9RPnou95eK1wEy myTQ== X-Gm-Message-State: APjAAAUgnxRuipqkUHA1SDafA55vpKp5PFVXOMlkHnR4bGoXLMINr6c8 cW7nd1fY+Fgci4alYKSE1KejKizF+0g= X-Google-Smtp-Source: APXvYqxjR2WxSwhz4bEAQUSsnKhYdiFcGxTT4ztRx+OINZ1XgoECTUXCVt0h4aXXCpow7/yuCP1reQ== X-Received: by 2002:a7b:c74a:: with SMTP id w10mr5674950wmk.30.1571934460028; Thu, 24 Oct 2019 09:27:40 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id r27sm42606124wrc.55.2019.10.24.09.27.38 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Oct 2019 09:27:38 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 10/51] target/arm: Split out rebuild_hflags_aprofile Date: Thu, 24 Oct 2019 17:26:43 +0100 Message-Id: <20191024162724.31675-11-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191024162724.31675-1-peter.maydell@linaro.org> References: <20191024162724.31675-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::342 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson Create a function to compute the values of the TBFLAG_ANY bits that will be cached, and are used by A-profile. Reviewed-by: Alex Bennée Signed-off-by: Richard Henderson Message-id: 20191023150057.25731-9-richard.henderson@linaro.org Signed-off-by: Peter Maydell --- target/arm/helper.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/target/arm/helper.c b/target/arm/helper.c index d1cd54cc931..ddd21edfcf1 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -11106,18 +11106,28 @@ static uint32_t rebuild_hflags_m32(CPUARMState *env, int fp_el, return rebuild_hflags_common_32(env, fp_el, mmu_idx, flags); } +static uint32_t rebuild_hflags_aprofile(CPUARMState *env) +{ + int flags = 0; + + flags = FIELD_DP32(flags, TBFLAG_ANY, DEBUG_TARGET_EL, + arm_debug_target_el(env)); + return flags; +} + static uint32_t rebuild_hflags_a32(CPUARMState *env, int fp_el, ARMMMUIdx mmu_idx) { - return rebuild_hflags_common_32(env, fp_el, mmu_idx, 0); + uint32_t flags = rebuild_hflags_aprofile(env); + return rebuild_hflags_common_32(env, fp_el, mmu_idx, flags); } static uint32_t rebuild_hflags_a64(CPUARMState *env, int el, int fp_el, ARMMMUIdx mmu_idx) { + uint32_t flags = rebuild_hflags_aprofile(env); ARMMMUIdx stage1 = stage_1_mmu_idx(mmu_idx); ARMVAParameters p0 = aa64_va_parameters_both(env, 0, stage1); - uint32_t flags = 0; uint64_t sctlr; int tbii, tbid; @@ -11262,12 +11272,6 @@ void cpu_get_tb_cpu_state(CPUARMState *env, target_ulong *pc, } } - if (!arm_feature(env, ARM_FEATURE_M)) { - int target_el = arm_debug_target_el(env); - - flags = FIELD_DP32(flags, TBFLAG_ANY, DEBUG_TARGET_EL, target_el); - } - *pflags = flags; *cs_base = 0; } From patchwork Thu Oct 24 16:26:44 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 11210367 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 78E121747 for ; Thu, 24 Oct 2019 17:03:49 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 4EDAB20650 for ; Thu, 24 Oct 2019 17:03:49 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="f+xZduZy" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4EDAB20650 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:48244 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNgWa-0003xi-2d for patchwork-qemu-devel@patchwork.kernel.org; Thu, 24 Oct 2019 13:03:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57801) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNfxg-0007C5-OI for qemu-devel@nongnu.org; Thu, 24 Oct 2019 12:27:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iNfxf-0000jo-K4 for qemu-devel@nongnu.org; Thu, 24 Oct 2019 12:27:44 -0400 Received: from mail-wm1-x342.google.com ([2a00:1450:4864:20::342]:39151) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iNfxf-0000jJ-EF for qemu-devel@nongnu.org; Thu, 24 Oct 2019 12:27:43 -0400 Received: by mail-wm1-x342.google.com with SMTP id r141so3205804wme.4 for ; Thu, 24 Oct 2019 09:27:43 -0700 (PDT) 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=zVsNlJ5N2k9sc9bIq4CoBW6EYZLcHxwA40pi1YP50Gg=; b=f+xZduZykPOGzSiLR04A1ZUnnV/7uoM9IOOoGmqo+xFRQXg6O93/kE3z5SvWXNMsHV INvWCuMfjzyfoh4O0DUxs4T2tJgiwmLHhj1c5CIzrPmsTU53MxcOq0qiCF8dbm5Fqrq/ D9DT8EHjxdY1AU+evC4e9WahTtJ1oK9bcuTQHMMc22tlsHJQEObtqjwUAzrjOSpZreSS iKyaVeEM6Gj8LpxKUonTdo6vTlDPU4fNfwZzCi4D6Q0qS9PKouyqJKwQ7T+KZIL9/OWx 3ObNgZJL+TZob9dwhgyB2mO01Qt5hpi001+dfvZxUI2nnHguoRus53OqBzBPXmgcmiLT o5uA== 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=zVsNlJ5N2k9sc9bIq4CoBW6EYZLcHxwA40pi1YP50Gg=; b=mtbYPlEWvjgBAeiZ6Wc/gXKYFc1Ey7fLtm9I876aRildITG56Bo9cz3X9QqktfAeM3 ka8JFf8XHXj84Jhl+Dh5ijZGhHErTjoWQxbdTPF3UGzJGng98ZA638xHSHCs09K2Y5I/ XL+/4GWvCa6HqAEjpBgehg44k7e2aiIPvvTbftYzMwlRsvA+dk7i4xsngCN4LbR6kasz Lb4HIPK9EzpTNV7zjNK6vOhVpLs9ullc4gEgoCR/Klf8ftsS+fK+S8RBuLMyvPqXFddL HgcLaX0S47SLbPHjxkyCaCScRzfruoAvitljJiPUd6YKtno0EqTikl4dnzcAi8W9H9O0 m8cA== X-Gm-Message-State: APjAAAXqIRcdYJ9p1D7GFHlhIKGQjN9hqAqjN6D0isbM//S/+ClA0Ssx t+YNHmmZTIiJ4YmiIEKOrkiREh9/YII= X-Google-Smtp-Source: APXvYqwyTfo6h5Mx+ZGqcKQ4WCXiQLKo2WdGvDi8qlf7A28S0LyXebmajJtZwfo0qC5FqPvMkD6fPA== X-Received: by 2002:a1c:2407:: with SMTP id k7mr5322298wmk.99.1571934461369; Thu, 24 Oct 2019 09:27:41 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id r27sm42606124wrc.55.2019.10.24.09.27.40 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Oct 2019 09:27:40 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 11/51] target/arm: Hoist XSCALE_CPAR, VECLEN, VECSTRIDE in cpu_get_tb_cpu_state Date: Thu, 24 Oct 2019 17:26:44 +0100 Message-Id: <20191024162724.31675-12-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191024162724.31675-1-peter.maydell@linaro.org> References: <20191024162724.31675-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::342 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson We do not need to compute any of these values for M-profile. Further, XSCALE_CPAR overlaps VECSTRIDE so obviously the two sets must be mutually exclusive. Reviewed-by: Alex Bennée Signed-off-by: Richard Henderson Message-id: 20191023150057.25731-10-richard.henderson@linaro.org Signed-off-by: Peter Maydell --- target/arm/helper.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/target/arm/helper.c b/target/arm/helper.c index ddd21edfcf1..e2a62cf19a0 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -11235,21 +11235,28 @@ void cpu_get_tb_cpu_state(CPUARMState *env, target_ulong *pc, } } else { flags = rebuild_hflags_a32(env, fp_el, mmu_idx); + + /* + * Note that XSCALE_CPAR shares bits with VECSTRIDE. + * Note that VECLEN+VECSTRIDE are RES0 for M-profile. + */ + if (arm_feature(env, ARM_FEATURE_XSCALE)) { + flags = FIELD_DP32(flags, TBFLAG_A32, + XSCALE_CPAR, env->cp15.c15_cpar); + } else { + flags = FIELD_DP32(flags, TBFLAG_A32, VECLEN, + env->vfp.vec_len); + flags = FIELD_DP32(flags, TBFLAG_A32, VECSTRIDE, + env->vfp.vec_stride); + } } flags = FIELD_DP32(flags, TBFLAG_A32, THUMB, env->thumb); - flags = FIELD_DP32(flags, TBFLAG_A32, VECLEN, env->vfp.vec_len); - flags = FIELD_DP32(flags, TBFLAG_A32, VECSTRIDE, env->vfp.vec_stride); flags = FIELD_DP32(flags, TBFLAG_A32, CONDEXEC, env->condexec_bits); if (env->vfp.xregs[ARM_VFP_FPEXC] & (1 << 30) || arm_el_is_aa64(env, 1) || arm_feature(env, ARM_FEATURE_M)) { flags = FIELD_DP32(flags, TBFLAG_A32, VFPEN, 1); } - /* Note that XSCALE_CPAR shares bits with VECSTRIDE */ - if (arm_feature(env, ARM_FEATURE_XSCALE)) { - flags = FIELD_DP32(flags, TBFLAG_A32, - XSCALE_CPAR, env->cp15.c15_cpar); - } } /* The SS_ACTIVE and PSTATE_SS bits correspond to the state machine From patchwork Thu Oct 24 16:26:45 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 11210247 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 485B214ED for ; Thu, 24 Oct 2019 16:42:15 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 1E2C320679 for ; Thu, 24 Oct 2019 16:42:15 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="LZ+vNWj/" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1E2C320679 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:47710 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNgBh-0008Te-KP for patchwork-qemu-devel@patchwork.kernel.org; Thu, 24 Oct 2019 12:42:13 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57807) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNfxh-0007Cv-50 for qemu-devel@nongnu.org; Thu, 24 Oct 2019 12:27:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iNfxf-0000k2-Vy for qemu-devel@nongnu.org; Thu, 24 Oct 2019 12:27:44 -0400 Received: from mail-wm1-x343.google.com ([2a00:1450:4864:20::343]:50860) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iNfxf-0000jU-PU for qemu-devel@nongnu.org; Thu, 24 Oct 2019 12:27:43 -0400 Received: by mail-wm1-x343.google.com with SMTP id 11so68825wmk.0 for ; Thu, 24 Oct 2019 09:27:43 -0700 (PDT) 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=0MGAigKQQJD7cJXlO5y60b4rzDCDAg5e78HpKgtRa3w=; b=LZ+vNWj/BJfxz9mI3hKgvf6n5hrg8oPyhZbNbpQ34O670N+KLXCD7K6qRTjWuFJlbc G/4vT3El4dH6Y6UDEUmOdEgX5w/pf+WtmKWH3plgyyJPvPsYF1MIbnzlbXPHTlZrvLd4 bYxe4XTUPzV9ScQOC48kBHvN3UU3lOPs53Lx/iqHiB5V91HEWsuURLxEjzJ9i4E61NqD AQ7I259Yl4IWVzeM+hDWDh+EPUrt78lDRt2KTKvmAyeQBRMaSsB5gh/t6rFtRTqswS4m 0lsAAamj5se+pD5rJ3iSb4/EZqMDaBiOXSM1TX+VWVvIv43q3Se0y/J6g83rWL1uEDaA Cpdw== 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=0MGAigKQQJD7cJXlO5y60b4rzDCDAg5e78HpKgtRa3w=; b=OBcQnfmtnbYbG6KuFlhYAVxRfFDHjVtgrDPYyqhtZEk61T9/CH+LSJFWCcPzJcFeaK C8nuqUljx4JGolUsqEvZwZ0eNZOK6KAwFg/EGWBjU+lxjD7HpiCXTbDfy0wcYXJqEajj Wv/b2LAOk12qi3XhivciluCY068HDqaOi2/NrwFszMqnvMZotEsxQB4pGV0jWRBi8Y7K AWMlG9Zu5zmzIe6DjJc5Auo+ExlCiMV99srJ5tnPJm2n+CFRzbJXcbELjMcaeBfTg8Ot LvbNjy6IKKtW3b8k2R0182kDUOcCLBHAfD7xQTKV/jNcj3MEQybrICrcJH3bfMSYKOf9 4/Kg== X-Gm-Message-State: APjAAAX0jOOl02ScYLpflUvreOAI+CuBtspZ8J4rtj39XgUr8qrlOpGA AO/SZ58ojcIcZjojQbCSPvlbiOZzGvg= X-Google-Smtp-Source: APXvYqxkWzTPXGHkmJlrDBhwhsJXO8s4V5LL0ReXu+Xcj8aPfvW98r59dGfnTusXJ+N2keO8zAb8Hg== X-Received: by 2002:a05:600c:2948:: with SMTP id n8mr5497183wmd.128.1571934462548; Thu, 24 Oct 2019 09:27:42 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id r27sm42606124wrc.55.2019.10.24.09.27.41 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Oct 2019 09:27:41 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 12/51] target/arm: Simplify set of PSTATE_SS in cpu_get_tb_cpu_state Date: Thu, 24 Oct 2019 17:26:45 +0100 Message-Id: <20191024162724.31675-13-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191024162724.31675-1-peter.maydell@linaro.org> References: <20191024162724.31675-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 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson Hoist the variable load for PSTATE into the existing test vs is_a64. Reviewed-by: Alex Bennée Signed-off-by: Richard Henderson Message-id: 20191023150057.25731-11-richard.henderson@linaro.org Signed-off-by: Peter Maydell --- target/arm/helper.c | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/target/arm/helper.c b/target/arm/helper.c index e2a62cf19a0..398e5f5d6df 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -11197,7 +11197,7 @@ void cpu_get_tb_cpu_state(CPUARMState *env, target_ulong *pc, ARMMMUIdx mmu_idx = arm_mmu_idx(env); int current_el = arm_current_el(env); int fp_el = fp_exception_el(env, current_el); - uint32_t flags; + uint32_t flags, pstate_for_ss; if (is_a64(env)) { *pc = env->pc; @@ -11205,6 +11205,7 @@ void cpu_get_tb_cpu_state(CPUARMState *env, target_ulong *pc, if (cpu_isar_feature(aa64_bti, env_archcpu(env))) { flags = FIELD_DP32(flags, TBFLAG_A64, BTYPE, env->btype); } + pstate_for_ss = env->pstate; } else { *pc = env->regs[15]; @@ -11257,9 +11258,11 @@ void cpu_get_tb_cpu_state(CPUARMState *env, target_ulong *pc, || arm_el_is_aa64(env, 1) || arm_feature(env, ARM_FEATURE_M)) { flags = FIELD_DP32(flags, TBFLAG_A32, VFPEN, 1); } + pstate_for_ss = env->uncached_cpsr; } - /* The SS_ACTIVE and PSTATE_SS bits correspond to the state machine + /* + * The SS_ACTIVE and PSTATE_SS bits correspond to the state machine * states defined in the ARM ARM for software singlestep: * SS_ACTIVE PSTATE.SS State * 0 x Inactive (the TB flag for SS is always 0) @@ -11267,16 +11270,9 @@ void cpu_get_tb_cpu_state(CPUARMState *env, target_ulong *pc, * 1 1 Active-not-pending * SS_ACTIVE is set in hflags; PSTATE_SS is computed every TB. */ - if (FIELD_EX32(flags, TBFLAG_ANY, SS_ACTIVE)) { - if (is_a64(env)) { - if (env->pstate & PSTATE_SS) { - flags = FIELD_DP32(flags, TBFLAG_ANY, PSTATE_SS, 1); - } - } else { - if (env->uncached_cpsr & PSTATE_SS) { - flags = FIELD_DP32(flags, TBFLAG_ANY, PSTATE_SS, 1); - } - } + if (FIELD_EX32(flags, TBFLAG_ANY, SS_ACTIVE) && + (pstate_for_ss & PSTATE_SS)) { + flags = FIELD_DP32(flags, TBFLAG_ANY, PSTATE_SS, 1); } *pflags = flags; From patchwork Thu Oct 24 16:26:46 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 11210397 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E0BAA112C for ; Thu, 24 Oct 2019 17:07:22 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id B2E5520650 for ; Thu, 24 Oct 2019 17:07:22 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="HBbVFcm7" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B2E5520650 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:48320 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNga1-00039b-1A for patchwork-qemu-devel@patchwork.kernel.org; Thu, 24 Oct 2019 13:07:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57823) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNfxi-0007Fb-CD for qemu-devel@nongnu.org; Thu, 24 Oct 2019 12:27:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iNfxh-0000kZ-35 for qemu-devel@nongnu.org; Thu, 24 Oct 2019 12:27:46 -0400 Received: from mail-wm1-x343.google.com ([2a00:1450:4864:20::343]:35411) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iNfxg-0000kA-T7 for qemu-devel@nongnu.org; Thu, 24 Oct 2019 12:27:45 -0400 Received: by mail-wm1-x343.google.com with SMTP id v6so3230674wmj.0 for ; Thu, 24 Oct 2019 09:27:44 -0700 (PDT) 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=VqhS9bMZKhIe/srTN0k3CkMWuCJ4HNLLhZjZXP6/VrQ=; b=HBbVFcm7p7x2mBLFqEsIWQsnAJhuO7aZ8DsgXOnz8TWYdIJcKDdxJoWwpINtXsjfCe +LrO4OEJpu/mhTekZ5THbIUbKcFU8ZpZLn48YKgK5g4gaRPlOEyv1x4R33SDsLaJhktP oyJtYl2ehjDHwKVDFwQaIFV9WXMCimyXHMbSgRlWfZEBaDT+/eYTTAdQuiZ/U8c16Z5k jUncw9YP4tdOf/AWPu8rNkqn+nizuL5lQSZ+tSXiDk35Ng3nXIUoFxCqBi0swBVhSvec fmIJORAadOoz3x34IvpTwN/ilR5iPvgCBTKi4tivX/Yefgswb0BwL5JUNpMSXl2O72mi znSw== 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=VqhS9bMZKhIe/srTN0k3CkMWuCJ4HNLLhZjZXP6/VrQ=; b=sUcNWQtkXBhHMmWZ+3zaFSqXfu+7RRjsBTPvlAmTaESPRrOZK+F0I7+i9kByEyqiOM og6JcHFZuStGe9ss+hs92pO4J+TD3hh39uxr7wXA4qisrCYIcg30qozkZ0lfVu0vznoy MuMLg31EyE7YDkrXVR0PzpAbNbr6iPHMIG32fH2pONwR9FLfoX5P5znEJjlEET2cZWSQ WgzXorB0JxDtikj3SAOLANLGUaiQ0pVrkA703TMPEjTXHWcgKzv804IdS4hibNBpzwil oen7vt2f17nwd/EZwI7q1+g0epgyaXt77bc8V68ZAbBi6N7L5A4c+a4dmQ1FS7ovhi9V ZqHg== X-Gm-Message-State: APjAAAWB7ykQ/qcmDZq2EG9wnD65D9gew2yyT6mULyHHO/9sjoXSaZMG /N+qyYNroDEDzSpN1jzz/2J1BaZK0eo= X-Google-Smtp-Source: APXvYqyRwkny1H5iMi+lElCRfVAYRqxActyTNCns9v3EC0IvlcqIhX+6Z4p/yKjizIXzUHxhVjd98A== X-Received: by 2002:a1c:7719:: with SMTP id t25mr5530940wmi.56.1571934463680; Thu, 24 Oct 2019 09:27:43 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id r27sm42606124wrc.55.2019.10.24.09.27.42 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Oct 2019 09:27:42 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 13/51] target/arm: Hoist computation of TBFLAG_A32.VFPEN Date: Thu, 24 Oct 2019 17:26:46 +0100 Message-Id: <20191024162724.31675-14-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191024162724.31675-1-peter.maydell@linaro.org> References: <20191024162724.31675-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 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson There are 3 conditions that each enable this flag. M-profile always enables; A-profile with EL1 as AA64 always enables. Both of these conditions can easily be cached. The final condition relies on the FPEXC register which we are not prepared to cache. Reviewed-by: Alex Bennée Signed-off-by: Richard Henderson Message-id: 20191023150057.25731-12-richard.henderson@linaro.org Signed-off-by: Peter Maydell --- target/arm/cpu.h | 2 +- target/arm/helper.c | 14 ++++++++++---- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/target/arm/cpu.h b/target/arm/cpu.h index 4d961474ce7..9909ff89d4f 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -3192,7 +3192,7 @@ FIELD(TBFLAG_A32, XSCALE_CPAR, 4, 2) * the same thing as the current security state of the processor! */ FIELD(TBFLAG_A32, NS, 6, 1) -FIELD(TBFLAG_A32, VFPEN, 7, 1) /* Not cached. */ +FIELD(TBFLAG_A32, VFPEN, 7, 1) /* Partially cached, minus FPEXC. */ FIELD(TBFLAG_A32, CONDEXEC, 8, 8) /* Not cached. */ FIELD(TBFLAG_A32, SCTLR_B, 16, 1) /* For M profile only, set if FPCCR.LSPACT is set */ diff --git a/target/arm/helper.c b/target/arm/helper.c index 398e5f5d6df..89aa6fd9339 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -11088,6 +11088,9 @@ static uint32_t rebuild_hflags_m32(CPUARMState *env, int fp_el, { uint32_t flags = 0; + /* v8M always enables the fpu. */ + flags = FIELD_DP32(flags, TBFLAG_A32, VFPEN, 1); + if (arm_v7m_is_handler_mode(env)) { flags = FIELD_DP32(flags, TBFLAG_A32, HANDLER, 1); } @@ -11119,6 +11122,10 @@ static uint32_t rebuild_hflags_a32(CPUARMState *env, int fp_el, ARMMMUIdx mmu_idx) { uint32_t flags = rebuild_hflags_aprofile(env); + + if (arm_el_is_aa64(env, 1)) { + flags = FIELD_DP32(flags, TBFLAG_A32, VFPEN, 1); + } return rebuild_hflags_common_32(env, fp_el, mmu_idx, flags); } @@ -11250,14 +11257,13 @@ void cpu_get_tb_cpu_state(CPUARMState *env, target_ulong *pc, flags = FIELD_DP32(flags, TBFLAG_A32, VECSTRIDE, env->vfp.vec_stride); } + if (env->vfp.xregs[ARM_VFP_FPEXC] & (1 << 30)) { + flags = FIELD_DP32(flags, TBFLAG_A32, VFPEN, 1); + } } flags = FIELD_DP32(flags, TBFLAG_A32, THUMB, env->thumb); flags = FIELD_DP32(flags, TBFLAG_A32, CONDEXEC, env->condexec_bits); - if (env->vfp.xregs[ARM_VFP_FPEXC] & (1 << 30) - || arm_el_is_aa64(env, 1) || arm_feature(env, ARM_FEATURE_M)) { - flags = FIELD_DP32(flags, TBFLAG_A32, VFPEN, 1); - } pstate_for_ss = env->uncached_cpsr; } From patchwork Thu Oct 24 16:26:47 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 11210405 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 49B21139A for ; Thu, 24 Oct 2019 17:10:18 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 1F9D620650 for ; Thu, 24 Oct 2019 17:10:18 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="sz4rEsZC" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1F9D620650 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:48370 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNgcq-0001K7-9D for patchwork-qemu-devel@patchwork.kernel.org; Thu, 24 Oct 2019 13:10:16 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57839) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNfxj-0007J1-Qn for qemu-devel@nongnu.org; Thu, 24 Oct 2019 12:27:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iNfxi-0000lA-CT for qemu-devel@nongnu.org; Thu, 24 Oct 2019 12:27:47 -0400 Received: from mail-wm1-x341.google.com ([2a00:1450:4864:20::341]:52639) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iNfxi-0000km-6D for qemu-devel@nongnu.org; Thu, 24 Oct 2019 12:27:46 -0400 Received: by mail-wm1-x341.google.com with SMTP id p21so2099344wmg.2 for ; Thu, 24 Oct 2019 09:27:46 -0700 (PDT) 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=yfXT1kAIXINflleiLaCvqElRIW5XZjl76Cc6V+HbJs0=; b=sz4rEsZC5067Tcw1a5qKvZXNWGWTTmlooa7k91VU7loXEdPnmyu6UWlaXdlFI8nwCo ZoSyoDi+t1JbjlfcQqypZN/g5THsHORvqyL0gV0CWUS291ShQSm5Sqp+DYfpJ94ecmtI 3+UBgB726qW33k08B+UmXfanT6X9J0pyIe5n/XznkgLTY7DjIwGQWuOwkIceRPuEACI3 fCBeTBNimppdZeCVM3jjgE5UOo+sPPCYPx9ZwBqzIPm+74tNhoBNC3Y9wg7yGuZWeZ5q DXkxhAdxljg1m3gc7ocM3xc0DhqM7/E7s7cI5pq95iHHCQFP9HZopTxJ82XElgmI3eFx jujw== 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=yfXT1kAIXINflleiLaCvqElRIW5XZjl76Cc6V+HbJs0=; b=ijCY2+A+IJwl6Db57IImyKP9mYUenW0PCIMbmgip16TK5mWrKtLj1scFSjbgU+RqlO crAtc0Jxp27edaCkP3WwrSYLQ05FZF4uwKzMndhi9MZsrVN0W9YzOEcG7QDm0an9LBxU Q+oe++9bKSaHmRmqTMUOgUgH/OsSTvME7xzI644KnDVSJtdjiSuO3P+8zxrV1oyKhBXQ 9lBPEjk3Y518WX3VdMW81RCUJeJ0uNiubRWSIPt6c4wJfmj76ZQYk99BYq14nKlsEHwN puvM4RSI+N5EBL8DDe0pJVhbix/LJQZNFwlyl23CZiwJx1WOmOxrwCNX1wKyGSCbVskM I/qQ== X-Gm-Message-State: APjAAAV2BTsW7BXSaGO/pOsG66Lk78hCdZCTs30EYcdHYiho4XAtzLWC LVayEVI8BSGdIGq6NshcZGtoCOTImn0= X-Google-Smtp-Source: APXvYqwwOH2gG1+LoDgTUXxisSYjLfVoW1HkUhpi6kwugrO1WbNsD7OzhsfCQFB15w1grmM8J8Js9Q== X-Received: by 2002:a1c:1b07:: with SMTP id b7mr5674683wmb.111.1571934464753; Thu, 24 Oct 2019 09:27:44 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id r27sm42606124wrc.55.2019.10.24.09.27.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Oct 2019 09:27:44 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 14/51] target/arm: Add arm_rebuild_hflags Date: Thu, 24 Oct 2019 17:26:47 +0100 Message-Id: <20191024162724.31675-15-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191024162724.31675-1-peter.maydell@linaro.org> References: <20191024162724.31675-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::341 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson This function assumes nothing about the current state of the cpu, and writes the computed value to env->hflags. Reviewed-by: Alex Bennée Signed-off-by: Richard Henderson Message-id: 20191023150057.25731-13-richard.henderson@linaro.org Signed-off-by: Peter Maydell --- target/arm/cpu.h | 6 ++++++ target/arm/helper.c | 30 ++++++++++++++++++++++-------- 2 files changed, 28 insertions(+), 8 deletions(-) diff --git a/target/arm/cpu.h b/target/arm/cpu.h index 9909ff89d4f..d844ea21d8d 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -3297,6 +3297,12 @@ void arm_register_pre_el_change_hook(ARMCPU *cpu, ARMELChangeHookFn *hook, void arm_register_el_change_hook(ARMCPU *cpu, ARMELChangeHookFn *hook, void *opaque); +/** + * arm_rebuild_hflags: + * Rebuild the cached TBFLAGS for arbitrary changed processor state. + */ +void arm_rebuild_hflags(CPUARMState *env); + /** * aa32_vfp_dreg: * Return a pointer to the Dn register within env in 32-bit mode. diff --git a/target/arm/helper.c b/target/arm/helper.c index 89aa6fd9339..85de96d071a 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -11198,17 +11198,35 @@ static uint32_t rebuild_hflags_a64(CPUARMState *env, int el, int fp_el, return rebuild_hflags_common(env, fp_el, mmu_idx, flags); } +static uint32_t rebuild_hflags_internal(CPUARMState *env) +{ + int el = arm_current_el(env); + int fp_el = fp_exception_el(env, el); + ARMMMUIdx mmu_idx = arm_mmu_idx(env); + + if (is_a64(env)) { + return rebuild_hflags_a64(env, el, fp_el, mmu_idx); + } else if (arm_feature(env, ARM_FEATURE_M)) { + return rebuild_hflags_m32(env, fp_el, mmu_idx); + } else { + return rebuild_hflags_a32(env, fp_el, mmu_idx); + } +} + +void arm_rebuild_hflags(CPUARMState *env) +{ + env->hflags = rebuild_hflags_internal(env); +} + void cpu_get_tb_cpu_state(CPUARMState *env, target_ulong *pc, target_ulong *cs_base, uint32_t *pflags) { - ARMMMUIdx mmu_idx = arm_mmu_idx(env); - int current_el = arm_current_el(env); - int fp_el = fp_exception_el(env, current_el); uint32_t flags, pstate_for_ss; + flags = rebuild_hflags_internal(env); + if (is_a64(env)) { *pc = env->pc; - flags = rebuild_hflags_a64(env, current_el, fp_el, mmu_idx); if (cpu_isar_feature(aa64_bti, env_archcpu(env))) { flags = FIELD_DP32(flags, TBFLAG_A64, BTYPE, env->btype); } @@ -11217,8 +11235,6 @@ void cpu_get_tb_cpu_state(CPUARMState *env, target_ulong *pc, *pc = env->regs[15]; if (arm_feature(env, ARM_FEATURE_M)) { - flags = rebuild_hflags_m32(env, fp_el, mmu_idx); - if (arm_feature(env, ARM_FEATURE_M_SECURITY) && FIELD_EX32(env->v7m.fpccr[M_REG_S], V7M_FPCCR, S) != env->v7m.secure) { @@ -11242,8 +11258,6 @@ void cpu_get_tb_cpu_state(CPUARMState *env, target_ulong *pc, flags = FIELD_DP32(flags, TBFLAG_A32, LSPACT, 1); } } else { - flags = rebuild_hflags_a32(env, fp_el, mmu_idx); - /* * Note that XSCALE_CPAR shares bits with VECSTRIDE. * Note that VECLEN+VECSTRIDE are RES0 for M-profile. From patchwork Thu Oct 24 16:26:48 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 11210361 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D7BDF1575 for ; Thu, 24 Oct 2019 17:01:26 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id AE37F20650 for ; Thu, 24 Oct 2019 17:01:26 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="pdRulk7B" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org AE37F20650 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:48200 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNgUH-0000L7-B5 for patchwork-qemu-devel@patchwork.kernel.org; Thu, 24 Oct 2019 13:01:25 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57854) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNfxk-0007LB-Ts for qemu-devel@nongnu.org; Thu, 24 Oct 2019 12:27:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iNfxj-0000mx-Kw for qemu-devel@nongnu.org; Thu, 24 Oct 2019 12:27:48 -0400 Received: from mail-wm1-x32d.google.com ([2a00:1450:4864:20::32d]:55099) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iNfxj-0000mH-Dw for qemu-devel@nongnu.org; Thu, 24 Oct 2019 12:27:47 -0400 Received: by mail-wm1-x32d.google.com with SMTP id g7so3535725wmk.4 for ; Thu, 24 Oct 2019 09:27:47 -0700 (PDT) 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=8v8h1OzrhCqLBFglLP5BbJjU1xr59SgzwhT/B4w8jqg=; b=pdRulk7Bgy7FfwfzpjIUgenzQhQ3N9sJvbVZkPjHIQPNuSqOqLSukBzq2JoRqhmZZq Ew1VYhiK7X82EQgcXstcuNKWsuRk31vwzDfZ60HV8yiHrOXm6ozfuk8nKFtXsQrOauRh I4wrUhlMOrjRi260eHoBfR5bGIdwQvBm/j2fxYs6nr6ONqiXPNdtziwNwX7dGIwAon1W mlXVr+ZbJlepl1MqkTFAnuLJ3CUgWPxJ2S/1WPB3GgeiatvI19KfUUb30m9uSg3aUK43 1KbDtpItEznxh/0m1ZQgXyVOXUpxeF6pCCyPlbmZOwRCOv7/lGwnawNJ4+43Wd3otpH9 vY6A== 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=8v8h1OzrhCqLBFglLP5BbJjU1xr59SgzwhT/B4w8jqg=; b=qWYD7tr+1FddjCN0euDUdJxhbbgqAZ5GGWIrP7QftbxGx970xGJFMfW+Q6r+fg34Ap W509DJF/eRUTAR8NzFp2UF5oAR/+bpIrDHzJ66zjOlJk6OHTEsxPJRZ97SZJ1ZZsj+dR ILkWhHZaS94zAm50/ntmSpT0gIjjzK8LOF05Q46p0itvDbFFi6xy6RY5hW8Q42Yo1+sW cD22PuxWQuFbeI51GmKKFoL1uklmzuUHrTph/5F4blCEN4mzLI18KmHWZvEcjvN/yrO4 NFkFaq2j+GOE2NP7JzkMZ5NfPryspv1wcYQMypzoa06mPbL3Vlmk1UUPdEpwsX65R+Ic Ym8w== X-Gm-Message-State: APjAAAXoiszbJF7r+yS6ar6I1yEGah07JwtcFfCCTx7KBe+UhCaJQzgL gFWL0I+3rwkXZUwxR0USEb4f+Q7JaYo= X-Google-Smtp-Source: APXvYqw5FPDxXpTrbZDTkBFM6OS9QnHUfYwd5sBGfYXySDhCGonExhvYoiNuvJe1gLoeJU9qzZ1ySQ== X-Received: by 2002:a1c:f709:: with SMTP id v9mr6023816wmh.62.1571934465909; Thu, 24 Oct 2019 09:27:45 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id r27sm42606124wrc.55.2019.10.24.09.27.44 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Oct 2019 09:27:45 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 15/51] target/arm: Split out arm_mmu_idx_el Date: Thu, 24 Oct 2019 17:26:48 +0100 Message-Id: <20191024162724.31675-16-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191024162724.31675-1-peter.maydell@linaro.org> References: <20191024162724.31675-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::32d X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson Avoid calling arm_current_el() twice. Reviewed-by: Alex Bennée Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson Message-id: 20191023150057.25731-14-richard.henderson@linaro.org Signed-off-by: Peter Maydell --- target/arm/internals.h | 9 +++++++++ target/arm/helper.c | 12 +++++++----- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/target/arm/internals.h b/target/arm/internals.h index 232d9638753..f5313dd3d42 100644 --- a/target/arm/internals.h +++ b/target/arm/internals.h @@ -949,6 +949,15 @@ void arm_cpu_update_virq(ARMCPU *cpu); */ void arm_cpu_update_vfiq(ARMCPU *cpu); +/** + * arm_mmu_idx_el: + * @env: The cpu environment + * @el: The EL to use. + * + * Return the full ARMMMUIdx for the translation regime for EL. + */ +ARMMMUIdx arm_mmu_idx_el(CPUARMState *env, int el); + /** * arm_mmu_idx: * @env: The cpu environment diff --git a/target/arm/helper.c b/target/arm/helper.c index 85de96d071a..3f7d3f257d8 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -11026,15 +11026,12 @@ ARMMMUIdx arm_v7m_mmu_idx_for_secstate(CPUARMState *env, bool secstate) } #endif -ARMMMUIdx arm_mmu_idx(CPUARMState *env) +ARMMMUIdx arm_mmu_idx_el(CPUARMState *env, int el) { - int el; - if (arm_feature(env, ARM_FEATURE_M)) { return arm_v7m_mmu_idx_for_secstate(env, env->v7m.secure); } - el = arm_current_el(env); if (el < 2 && arm_is_secure_below_el3(env)) { return ARMMMUIdx_S1SE0 + el; } else { @@ -11042,6 +11039,11 @@ ARMMMUIdx arm_mmu_idx(CPUARMState *env) } } +ARMMMUIdx arm_mmu_idx(CPUARMState *env) +{ + return arm_mmu_idx_el(env, arm_current_el(env)); +} + int cpu_mmu_index(CPUARMState *env, bool ifetch) { return arm_to_core_mmu_idx(arm_mmu_idx(env)); @@ -11202,7 +11204,7 @@ static uint32_t rebuild_hflags_internal(CPUARMState *env) { int el = arm_current_el(env); int fp_el = fp_exception_el(env, el); - ARMMMUIdx mmu_idx = arm_mmu_idx(env); + ARMMMUIdx mmu_idx = arm_mmu_idx_el(env, el); if (is_a64(env)) { return rebuild_hflags_a64(env, el, fp_el, mmu_idx); From patchwork Thu Oct 24 16:26:49 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 11210249 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id CDA4813B1 for ; Thu, 24 Oct 2019 16:45:20 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A437420659 for ; Thu, 24 Oct 2019 16:45:20 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="RQXhPimm" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A437420659 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:47812 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNgEg-0006IQ-BG for patchwork-qemu-devel@patchwork.kernel.org; Thu, 24 Oct 2019 12:45:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57874) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNfxl-0007NO-VF for qemu-devel@nongnu.org; Thu, 24 Oct 2019 12:27:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iNfxl-0000nj-1s for qemu-devel@nongnu.org; Thu, 24 Oct 2019 12:27:49 -0400 Received: from mail-wm1-x32a.google.com ([2a00:1450:4864:20::32a]:38221) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iNfxk-0000nJ-Rj for qemu-devel@nongnu.org; Thu, 24 Oct 2019 12:27:48 -0400 Received: by mail-wm1-x32a.google.com with SMTP id 3so3219201wmi.3 for ; Thu, 24 Oct 2019 09:27:48 -0700 (PDT) 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=BZJHPhd7AksEx+H4Cy3rMhdQWffeBwbM7nZoccEAv4g=; b=RQXhPimmHEf6xAGxFC3DC1voMcBGEKGk3qf51Fq46Ss8d8IGR29OAUG4jCASSR4edk d2aEfQpv6SeZTkNpkj26hV1Rqjome8auSz3I4nGsX1G2SxW9GbXDCkd91MRh2JbGE55G 3Sw4x+rqLFfuML0D6+B7CtJx9WJ1sVS5zGcojYugJLiPqvNTndlZra5YwiNUbLZof9ON azVQ6viNTTmIIDBTltIW6xA5rHTOZsCwaTnbrUlnCbrADiQ7cLhTj6NBmFjB156UBqqw CvkolqJmBp7toy/RjSh8YVk/FnSoglm4qv0BdqMoNcT66I1DQaSXTWAo41Cs4Zd/3HWG m03g== 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=BZJHPhd7AksEx+H4Cy3rMhdQWffeBwbM7nZoccEAv4g=; b=WmqbpRroaxN2hDVLxygGQ2tfnN2OWV7RlRo3mTWd38p7Qc4qg7TMKwAcMrOSvttf7x cuxsxTTa2rExy1scJ4/taw/f1o0piAb2GslbYYK5X3KYtkU+KaoYpggF/XNtRaio8JoH ewu/rwmDLJowgjhtokQEUsyDzMPDj3SX86EX7k45MMA8+QB7kTijK0rahMa6rxb3G7pi 9aS/YAJ+lJinGgMe8G5UFjTSteL5yaBL+xI9Jf2WRd8s4E3hyOABf3EIkcrRC/ZkHAVr 8XsuDEa7WwJecc7z51wBv0niI8x6d7cKn3CHJK+dsRK+/GBY0X4vIW2/t+B8eug2SxCK SPQg== X-Gm-Message-State: APjAAAXHop6G5VOArORkQDbeOPXa9LYyxVcHIgLbnFW/uzxkGMCRnl4v uuxum3KU6IbfPwKxVTsDTSqkZwAW7co= X-Google-Smtp-Source: APXvYqzALxotPMAiGlloMpeCPRe1blQZ/IYm1ELXdkZFUAZmJAUT9HAc3U7dFCp1wfHbp/nGDneeaw== X-Received: by 2002:a7b:c753:: with SMTP id w19mr6111263wmk.25.1571934467581; Thu, 24 Oct 2019 09:27:47 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id r27sm42606124wrc.55.2019.10.24.09.27.45 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Oct 2019 09:27:46 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 16/51] target/arm: Hoist store to cs_base in cpu_get_tb_cpu_state Date: Thu, 24 Oct 2019 17:26:49 +0100 Message-Id: <20191024162724.31675-17-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191024162724.31675-1-peter.maydell@linaro.org> References: <20191024162724.31675-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::32a X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson By performing this store early, we avoid having to save and restore the register holding the address around any function calls. Reviewed-by: Alex Bennée Signed-off-by: Richard Henderson Message-id: 20191023150057.25731-15-richard.henderson@linaro.org Signed-off-by: Peter Maydell --- target/arm/helper.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target/arm/helper.c b/target/arm/helper.c index 3f7d3f257d8..37424e3d4dd 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -11225,6 +11225,7 @@ void cpu_get_tb_cpu_state(CPUARMState *env, target_ulong *pc, { uint32_t flags, pstate_for_ss; + *cs_base = 0; flags = rebuild_hflags_internal(env); if (is_a64(env)) { @@ -11298,7 +11299,6 @@ void cpu_get_tb_cpu_state(CPUARMState *env, target_ulong *pc, } *pflags = flags; - *cs_base = 0; } #ifdef TARGET_AARCH64 From patchwork Thu Oct 24 16:26:50 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 11210399 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8F924112C for ; Thu, 24 Oct 2019 17:07:25 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 657F820650 for ; Thu, 24 Oct 2019 17:07:25 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="CgF4v0w7" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 657F820650 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:48324 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNga4-0003IW-42 for patchwork-qemu-devel@patchwork.kernel.org; Thu, 24 Oct 2019 13:07:24 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57895) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNfxn-0007Pi-Qr for qemu-devel@nongnu.org; Thu, 24 Oct 2019 12:27:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iNfxm-0000oO-Kk for qemu-devel@nongnu.org; Thu, 24 Oct 2019 12:27:51 -0400 Received: from mail-wr1-x42d.google.com ([2a00:1450:4864:20::42d]:46187) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iNfxm-0000o5-Ee for qemu-devel@nongnu.org; Thu, 24 Oct 2019 12:27:50 -0400 Received: by mail-wr1-x42d.google.com with SMTP id n15so16009048wrw.13 for ; Thu, 24 Oct 2019 09:27:50 -0700 (PDT) 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=QUTF96nfti+DI0q+OP0hhjq9ZudXZCCZu7o5L2KL3Xc=; b=CgF4v0w7Ch4pv6uqfAaj6aoEIUd1eYNcqDlUMirVC7/ePRFwlgmw7vlwpXtow6k0m9 RFnZaVKO1S7rvTqS57CSIAzC90qXt13XZ/CGwP+PX+iR9KSpac93vmpFosRygwlxtypx E7IgCFvv89/2puDJdDS88oYU7L3dTkUCaV1ZAH5BEv9WPfKrShYGozepuSP311H3SfkQ 90cOX1sZdAjkve8ONMDESzGS+74eOtejCAAT/G3sXtl2AnsafUMbC+k+rky9XEJUgpI3 g3d5oNFlmwMiprB1OhxYYoLGCS/I3biYEAPL1ebIGb4pKD+zjZJZqFY1UyJdoCdQkIHQ qkLA== 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=QUTF96nfti+DI0q+OP0hhjq9ZudXZCCZu7o5L2KL3Xc=; b=ijfJkfp8mnhjnHehY1wQaH7Joj+Ey6uZd+rPE4hGSH5OscCThVxsUlKhl1ixde4w4n 1F+bFXIcHYl5i+KRPvDzK6vA+1e8NgHf04UEZhHCN9xWK1ZvPjsVuIogSKwX/FxkF0ZN lqW6QpX+AbNqZ+8yw9gnYaIS2VnQCY9xUToN8EDMDLg3pSJ8UMX6MHA457ssdsm6jjF8 gt7U4B214QC18rhlEYE4O3V7llY5ieYf3FtMdjWrP3UyY2deHRNhslFJ76zcfMjvkLgW PE9+xAFuo7vaiane0yOiyb+e3+cJthvYhlUwECVpg68gNkugXR+d8AOyKu+jjN3pbG38 aK5A== X-Gm-Message-State: APjAAAXOhaLlYYmDJTBcBTXT9+2GgnjEuTts9S7UIFqYRYV8sGAq9IHI 78dsGX4DWxfV2TvQ3Z+Yl3U7Rnz93Dc= X-Google-Smtp-Source: APXvYqwYzIAoxBN/NwYshtdky3UYo2667QDCgMVf8+9FBBMXVrUztP8s6RdqG9G7JKPE2wCei+sEiQ== X-Received: by 2002:a05:6000:4f:: with SMTP id k15mr4414830wrx.137.1571934468647; Thu, 24 Oct 2019 09:27:48 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id r27sm42606124wrc.55.2019.10.24.09.27.47 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Oct 2019 09:27:47 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 17/51] target/arm: Add HELPER(rebuild_hflags_{a32, a64, m32}) Date: Thu, 24 Oct 2019 17:26:50 +0100 Message-Id: <20191024162724.31675-18-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191024162724.31675-1-peter.maydell@linaro.org> References: <20191024162724.31675-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::42d X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson This functions are given the mode and el state of the cpu and writes the computed value to env->hflags. Reviewed-by: Alex Bennée Signed-off-by: Richard Henderson Message-id: 20191023150057.25731-16-richard.henderson@linaro.org Signed-off-by: Peter Maydell --- target/arm/helper.h | 4 ++++ target/arm/helper.c | 24 ++++++++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/target/arm/helper.h b/target/arm/helper.h index 1fb2cb5a777..3d4ec267a2c 100644 --- a/target/arm/helper.h +++ b/target/arm/helper.h @@ -90,6 +90,10 @@ DEF_HELPER_4(msr_banked, void, env, i32, i32, i32) DEF_HELPER_2(get_user_reg, i32, env, i32) DEF_HELPER_3(set_user_reg, void, env, i32, i32) +DEF_HELPER_FLAGS_2(rebuild_hflags_m32, TCG_CALL_NO_RWG, void, env, int) +DEF_HELPER_FLAGS_2(rebuild_hflags_a32, TCG_CALL_NO_RWG, void, env, int) +DEF_HELPER_FLAGS_2(rebuild_hflags_a64, TCG_CALL_NO_RWG, void, env, int) + DEF_HELPER_1(vfp_get_fpscr, i32, env) DEF_HELPER_2(vfp_set_fpscr, void, env, i32) diff --git a/target/arm/helper.c b/target/arm/helper.c index 37424e3d4dd..b2d701cf004 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -11220,6 +11220,30 @@ void arm_rebuild_hflags(CPUARMState *env) env->hflags = rebuild_hflags_internal(env); } +void HELPER(rebuild_hflags_m32)(CPUARMState *env, int el) +{ + int fp_el = fp_exception_el(env, el); + ARMMMUIdx mmu_idx = arm_mmu_idx_el(env, el); + + env->hflags = rebuild_hflags_m32(env, fp_el, mmu_idx); +} + +void HELPER(rebuild_hflags_a32)(CPUARMState *env, int el) +{ + int fp_el = fp_exception_el(env, el); + ARMMMUIdx mmu_idx = arm_mmu_idx_el(env, el); + + env->hflags = rebuild_hflags_a32(env, fp_el, mmu_idx); +} + +void HELPER(rebuild_hflags_a64)(CPUARMState *env, int el) +{ + int fp_el = fp_exception_el(env, el); + ARMMMUIdx mmu_idx = arm_mmu_idx_el(env, el); + + env->hflags = rebuild_hflags_a64(env, el, fp_el, mmu_idx); +} + void cpu_get_tb_cpu_state(CPUARMState *env, target_ulong *pc, target_ulong *cs_base, uint32_t *pflags) { From patchwork Thu Oct 24 16:26:51 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 11210369 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id AB150913 for ; Thu, 24 Oct 2019 17:04:47 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 80C3820650 for ; Thu, 24 Oct 2019 17:04:47 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="CSLUh47a" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 80C3820650 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:48256 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNgXW-0006Xl-2Z for patchwork-qemu-devel@patchwork.kernel.org; Thu, 24 Oct 2019 13:04:46 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57904) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNfxo-0007Qn-Dz for qemu-devel@nongnu.org; Thu, 24 Oct 2019 12:27:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iNfxn-0000oc-2O for qemu-devel@nongnu.org; Thu, 24 Oct 2019 12:27:52 -0400 Received: from mail-wm1-x32d.google.com ([2a00:1450:4864:20::32d]:36641) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iNfxm-0000oH-Sd for qemu-devel@nongnu.org; Thu, 24 Oct 2019 12:27:51 -0400 Received: by mail-wm1-x32d.google.com with SMTP id c22so3225427wmd.1 for ; Thu, 24 Oct 2019 09:27:50 -0700 (PDT) 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=IVPjk80/vMxw/zuAjIrvBHIged7KPUhTphMMQkeon5g=; b=CSLUh47aZB0XE4LqNXyIeDwTL4Hfmnhxd8FZBdvPQT/6fTZQx02xLEOxV9ImVW8UfX Rrtzh+GaZXD7YPyHaqcqyTb0PwHR/txhM4dVHucBW8E/Lzlc7sv4f+XyxrabouE89EKM 8x5uBX9UUCXiUWGNwGCuwMlvZHSXjvDD6Q25Ycji+inr6E/pviyaD+TibcTFEeiz4Yhj cQuhxVrYe6ppq926dS2dCZJgxoofYMYtLxzryvcDX9/BLTJQrTm4/iOVc5mV4RJjD/Ef kIHrGqZ0z4qJkhtDvupo3zs4YYcCRWyInefaeN2pJsR2jy4xi2m+u8Rq2YNNaVlMNTWX /OGg== 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=IVPjk80/vMxw/zuAjIrvBHIged7KPUhTphMMQkeon5g=; b=ci3l2Hl6qhzVvHn5pkhfBMaVvxB5b3FTGF1JvtHqfkmEYmNAB80o3OYd+OY5TaCnIg C12Oyvm/wexUq+IhLYCsErdUxh1H4tWyp3wbTm7vjbiQRCSt+FaigGJzSrZdk0WjNZmJ eZuZPHc6WawHiiv1+Fm383qeS+FfsQ8YjDqt/Folg6yOD3Ng+b245NL2jFpQid12vVQS CIHuRaYSYvKBW61ypqb5g6wazDUU3aJLrBYTXwrX/TPJo/s4umU21IzhpKoz9xjyzw83 y1AzfQBlOGTIntEIViZTkWvTSJE5UjEvO3+/OJSbsDpOBwq+k6HBLrEXmyyrLkr482aR 6SjQ== X-Gm-Message-State: APjAAAXRH6/7oUYEzy9ajxXrARePt+/Opd3S5+DDDDWBPXG8MdFymRI4 zBR3wQnpDdSAfO8cX+Y3644ncR81/FQ= X-Google-Smtp-Source: APXvYqxZRw2F1vc3iUEiNRNqOP/TTYD3FI/0RO6OZAXhSnbKQ1UAgSVXZg9/ewE5bQvyIh9VBOGjmQ== X-Received: by 2002:a7b:cf36:: with SMTP id m22mr5421716wmg.98.1571934469681; Thu, 24 Oct 2019 09:27:49 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id r27sm42606124wrc.55.2019.10.24.09.27.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Oct 2019 09:27:49 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 18/51] target/arm: Rebuild hflags at EL changes Date: Thu, 24 Oct 2019 17:26:51 +0100 Message-Id: <20191024162724.31675-19-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191024162724.31675-1-peter.maydell@linaro.org> References: <20191024162724.31675-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::32d X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson Begin setting, but not relying upon, env->hflags. Reviewed-by: Alex Bennée Signed-off-by: Richard Henderson Message-id: 20191023150057.25731-17-richard.henderson@linaro.org Signed-off-by: Peter Maydell --- linux-user/syscall.c | 1 + target/arm/cpu.c | 1 + target/arm/helper-a64.c | 3 +++ target/arm/helper.c | 2 ++ target/arm/machine.c | 1 + target/arm/op_helper.c | 1 + 6 files changed, 9 insertions(+) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index f1ab81b9177..530c8433036 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -9984,6 +9984,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, aarch64_sve_narrow_vq(env, vq); } env->vfp.zcr_el[1] = vq - 1; + arm_rebuild_hflags(env); ret = vq * 16; } return ret; diff --git a/target/arm/cpu.c b/target/arm/cpu.c index 13813fb2135..ab3e1a03616 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -406,6 +406,7 @@ static void arm_cpu_reset(CPUState *s) hw_breakpoint_update_all(cpu); hw_watchpoint_update_all(cpu); + arm_rebuild_hflags(env); } bool arm_cpu_exec_interrupt(CPUState *cs, int interrupt_request) diff --git a/target/arm/helper-a64.c b/target/arm/helper-a64.c index bca80bdc38b..b4cd680fc48 100644 --- a/target/arm/helper-a64.c +++ b/target/arm/helper-a64.c @@ -1025,6 +1025,7 @@ void HELPER(exception_return)(CPUARMState *env, uint64_t new_pc) } else { env->regs[15] = new_pc & ~0x3; } + helper_rebuild_hflags_a32(env, new_el); qemu_log_mask(CPU_LOG_INT, "Exception return from AArch64 EL%d to " "AArch32 EL%d PC 0x%" PRIx32 "\n", cur_el, new_el, env->regs[15]); @@ -1036,10 +1037,12 @@ void HELPER(exception_return)(CPUARMState *env, uint64_t new_pc) } aarch64_restore_sp(env, new_el); env->pc = new_pc; + helper_rebuild_hflags_a64(env, new_el); qemu_log_mask(CPU_LOG_INT, "Exception return from AArch64 EL%d to " "AArch64 EL%d PC 0x%" PRIx64 "\n", cur_el, new_el, env->pc); } + /* * Note that cur_el can never be 0. If new_el is 0, then * el0_a64 is return_to_aa64, else el0_a64 is ignored. diff --git a/target/arm/helper.c b/target/arm/helper.c index b2d701cf004..aae7b62458f 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -7998,6 +7998,7 @@ static void take_aarch32_exception(CPUARMState *env, int new_mode, env->regs[14] = env->regs[15] + offset; } env->regs[15] = newpc; + arm_rebuild_hflags(env); } static void arm_cpu_do_interrupt_aarch32_hyp(CPUState *cs) @@ -8345,6 +8346,7 @@ static void arm_cpu_do_interrupt_aarch64(CPUState *cs) pstate_write(env, PSTATE_DAIF | new_mode); env->aarch64 = 1; aarch64_restore_sp(env, new_el); + helper_rebuild_hflags_a64(env, new_el); env->pc = addr; diff --git a/target/arm/machine.c b/target/arm/machine.c index 5c36707a7c9..eb28b2381bb 100644 --- a/target/arm/machine.c +++ b/target/arm/machine.c @@ -756,6 +756,7 @@ static int cpu_post_load(void *opaque, int version_id) if (!kvm_enabled()) { pmu_op_finish(&cpu->env); } + arm_rebuild_hflags(&cpu->env); return 0; } diff --git a/target/arm/op_helper.c b/target/arm/op_helper.c index 0fd4bd02385..ccc2cecb467 100644 --- a/target/arm/op_helper.c +++ b/target/arm/op_helper.c @@ -404,6 +404,7 @@ void HELPER(cpsr_write_eret)(CPUARMState *env, uint32_t val) * state. Do the masking now. */ env->regs[15] &= (env->thumb ? ~1 : ~3); + arm_rebuild_hflags(env); qemu_mutex_lock_iothread(); arm_call_el_change_hook(env_archcpu(env)); From patchwork Thu Oct 24 16:26:52 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 11210327 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2C60F14E5 for ; Thu, 24 Oct 2019 16:49:20 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 012D820659 for ; Thu, 24 Oct 2019 16:49:20 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="CWKNZRu5" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 012D820659 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:47964 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNgIZ-0004lU-6s for patchwork-qemu-devel@patchwork.kernel.org; Thu, 24 Oct 2019 12:49:19 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57926) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNfxq-0007Th-JW for qemu-devel@nongnu.org; Thu, 24 Oct 2019 12:27:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iNfxo-0000pA-93 for qemu-devel@nongnu.org; Thu, 24 Oct 2019 12:27:54 -0400 Received: from mail-wr1-x434.google.com ([2a00:1450:4864:20::434]:46194) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iNfxo-0000om-2p for qemu-devel@nongnu.org; Thu, 24 Oct 2019 12:27:52 -0400 Received: by mail-wr1-x434.google.com with SMTP id n15so16009145wrw.13 for ; Thu, 24 Oct 2019 09:27:52 -0700 (PDT) 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=OcDwolq811QfFGrcusum3clsrtTFTFlEcKsQCy0b1II=; b=CWKNZRu50x3NXUtb5L3mJRGn3uqHj8atMRMa95upiM9i4WgIAwDPOX7j8qvdr7lTa8 h13k0I56j1ZnI5SMDUQpuFAvbywcLk7LnnwVnZvd0jCy44wrieXULyAUEZoZ1+RJm79S IpUtDw9RSzIKAldSCbfjRG8m08Vrqltu6lb6Oe4OfmsDdAu1TB2Bi1JxoHCbeK4TNd2J i4C0sb8+m8R2Hwd6sDVnTJDv97bWBw7wCtRPhw51TqebSbS6MZvh1beYcVeobKl0lYzu N+EFUpRbwZpkwSszCxfj4FOeq6XqQNCtd1ztCEPT4E7YbFoeacMKC692YUm1y/WAGH8D xn0Q== 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=OcDwolq811QfFGrcusum3clsrtTFTFlEcKsQCy0b1II=; b=IrTVG3s+mYe1YJskhgkdX2wqcDD4rNjTakwzY6PB4W+J25+cna0QNvuRLSoasb2L0f edNZrf2kzp5nBdhCv/FTuOdf2maP2uttLqoX5A33Pb/QkprHQBHYZds9LIH0Qh/LeFjZ FqR2JfDmFBe1FOANYUOzo0Nau1huHD/dIMQoUKbvw7FDSvpCLUoaS3cyM4uvllD8cO5c 3MxtjQaW4xBkyVEod/5aHvUAydjYkk9NB6TlcLmINnBGN/vv/JKAN40Gi2xG0SVk32Ur +Vc5ityqWEcp0FZukvjnTbXhxKRywwB3XQ+cH0VnJN8jsoOzBomjMOXMRu8M2mRgvZlP fdIA== X-Gm-Message-State: APjAAAW7xjf7UTxZaTWg0X7d/KNmUw8P/BnT+PMh6VEA8EVmK/GbQyQ9 Pjkudm4UfJdL2IZ/+Tp2hgIe9U/++lk= X-Google-Smtp-Source: APXvYqycShgE8A0+nHVrrQ4vQr+m5eAkGPqLHnykvt+9i7KeT/BkpYw2ibwtC4+FBxXhUb37nhO8gQ== X-Received: by 2002:a05:6000:34f:: with SMTP id e15mr5073912wre.232.1571934470892; Thu, 24 Oct 2019 09:27:50 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id r27sm42606124wrc.55.2019.10.24.09.27.49 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Oct 2019 09:27:50 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 19/51] target/arm: Rebuild hflags at MSR writes Date: Thu, 24 Oct 2019 17:26:52 +0100 Message-Id: <20191024162724.31675-20-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191024162724.31675-1-peter.maydell@linaro.org> References: <20191024162724.31675-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 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson Continue setting, but not relying upon, env->hflags. Reviewed-by: Alex Bennée Signed-off-by: Richard Henderson Message-id: 20191023150057.25731-18-richard.henderson@linaro.org Signed-off-by: Peter Maydell --- target/arm/translate-a64.c | 13 +++++++++++-- target/arm/translate.c | 28 +++++++++++++++++++++++----- 2 files changed, 34 insertions(+), 7 deletions(-) diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c index 2d6cd09634c..d4bebbe6295 100644 --- a/target/arm/translate-a64.c +++ b/target/arm/translate-a64.c @@ -1789,8 +1789,17 @@ static void handle_sys(DisasContext *s, uint32_t insn, bool isread, if ((tb_cflags(s->base.tb) & CF_USE_ICOUNT) && (ri->type & ARM_CP_IO)) { /* I/O operations must end the TB here (whether read or write) */ s->base.is_jmp = DISAS_UPDATE; - } else if (!isread && !(ri->type & ARM_CP_SUPPRESS_TB_END)) { - /* We default to ending the TB on a coprocessor register write, + } + if (!isread && !(ri->type & ARM_CP_SUPPRESS_TB_END)) { + /* + * A write to any coprocessor regiser that ends a TB + * must rebuild the hflags for the next TB. + */ + TCGv_i32 tcg_el = tcg_const_i32(s->current_el); + gen_helper_rebuild_hflags_a64(cpu_env, tcg_el); + tcg_temp_free_i32(tcg_el); + /* + * We default to ending the TB on a coprocessor register write, * but allow this to be suppressed by the register definition * (usually only necessary to work around guest bugs). */ diff --git a/target/arm/translate.c b/target/arm/translate.c index 96340520ee2..46a0bf51c95 100644 --- a/target/arm/translate.c +++ b/target/arm/translate.c @@ -6890,6 +6890,8 @@ static int disas_coproc_insn(DisasContext *s, uint32_t insn) ri = get_arm_cp_reginfo(s->cp_regs, ENCODE_CP_REG(cpnum, is64, s->ns, crn, crm, opc1, opc2)); if (ri) { + bool need_exit_tb; + /* Check access permissions */ if (!cp_access_ok(s->current_el, ri, isread)) { return 1; @@ -7068,14 +7070,30 @@ static int disas_coproc_insn(DisasContext *s, uint32_t insn) } } - if ((tb_cflags(s->base.tb) & CF_USE_ICOUNT) && (ri->type & ARM_CP_IO)) { - /* I/O operations must end the TB here (whether read or write) */ - gen_lookup_tb(s); - } else if (!isread && !(ri->type & ARM_CP_SUPPRESS_TB_END)) { - /* We default to ending the TB on a coprocessor register write, + /* I/O operations must end the TB here (whether read or write) */ + need_exit_tb = ((tb_cflags(s->base.tb) & CF_USE_ICOUNT) && + (ri->type & ARM_CP_IO)); + + if (!isread && !(ri->type & ARM_CP_SUPPRESS_TB_END)) { + /* + * A write to any coprocessor regiser that ends a TB + * must rebuild the hflags for the next TB. + */ + TCGv_i32 tcg_el = tcg_const_i32(s->current_el); + if (arm_dc_feature(s, ARM_FEATURE_M)) { + gen_helper_rebuild_hflags_m32(cpu_env, tcg_el); + } else { + gen_helper_rebuild_hflags_a32(cpu_env, tcg_el); + } + tcg_temp_free_i32(tcg_el); + /* + * We default to ending the TB on a coprocessor register write, * but allow this to be suppressed by the register definition * (usually only necessary to work around guest bugs). */ + need_exit_tb = true; + } + if (need_exit_tb) { gen_lookup_tb(s); } From patchwork Thu Oct 24 16:26:53 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 11210331 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8907814ED for ; Thu, 24 Oct 2019 16:52:35 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 5F82620659 for ; Thu, 24 Oct 2019 16:52:35 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="UmIp1ToZ" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5F82620659 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:48024 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNgLi-0002hH-03 for patchwork-qemu-devel@patchwork.kernel.org; Thu, 24 Oct 2019 12:52:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57934) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNfxs-0007Uw-9v for qemu-devel@nongnu.org; Thu, 24 Oct 2019 12:27:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iNfxq-0000pk-4Q for qemu-devel@nongnu.org; Thu, 24 Oct 2019 12:27:55 -0400 Received: from mail-wr1-x432.google.com ([2a00:1450:4864:20::432]:38853) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iNfxp-0000pV-UR for qemu-devel@nongnu.org; Thu, 24 Oct 2019 12:27:54 -0400 Received: by mail-wr1-x432.google.com with SMTP id v9so15523861wrq.5 for ; Thu, 24 Oct 2019 09:27:53 -0700 (PDT) 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=XZeplV9UvaCL/Xmc97dVbloX+PjjbYg7Xk7yU5JEklc=; b=UmIp1ToZEDwVtWzTJOSPTNLb+Z5nrTM6M1pAOtvCibwT9pJQM6Ryv1okjYldM91zVU f8ustqD+3hpZUUBFrWcq41tDtExND40iPOx0O1BFkt4LqJIike9s6/TyVzCW14hdbBug lC/uf0qRSs0+7CsScrwHlx0T/Zj+3JnhGtSTJTX43h3b+Vkv9VYvIdgo1uOSW5qmlvXz f2cmuMW0yDjV8WSKY8l0OJaYJ9bITJLaSVWkcjq7eiqMlgkA+0DVaJwtaHl8gM6a6okJ k7Ds9JHrorgdjiHfTSeCTRojXurBT3uDPI1CGyrRIcefTnkv604nD75zEjmW/nUY9qmr AvEA== 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=XZeplV9UvaCL/Xmc97dVbloX+PjjbYg7Xk7yU5JEklc=; b=P6eB5KV+/0q8YvEErS29s4936rNKJmpos8V3FBPoq0mXdBRIwZNg0pb2IzYK29JNpd 03UICbXHfyWJ5ZQMOsKg77aWm6a0hLSMvZVjEWyjHpitC1iIjMfO0khfD/6HswwbT53g HvABMBmOSNcROaDJPAkGPK0sYOJnTiGk5IGVvzp7RnrPq9peUu3l9qPpph+amregPVF+ cE/N5tsrFbk5pUsadZfDskyhobHYexepCctH8rhF9LS0Ikm1ktccEetYkGR+MjsYVacL S1ycuUa1xfKHjrPvqsvnXG000t/tbg2Pi3vgQcDasdzqViS7gVRInCMyBNF0b2NNXDUk kLog== X-Gm-Message-State: APjAAAXRsz+Ih7gXLqjU2+B4QZcDL/z9OAPceCscQss7d+sA/RtYToYl 3dvlpzGsDBZIJbJYceM/TpPgMZS+Fnw= X-Google-Smtp-Source: APXvYqxT7AP6OK4/viRjpw4ldwh0bsHYWUSvYpj0yJtf/12T3huupLBfmZAcGgEjfIS9702jX9Pt0w== X-Received: by 2002:a5d:464f:: with SMTP id j15mr4658132wrs.366.1571934472678; Thu, 24 Oct 2019 09:27:52 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id r27sm42606124wrc.55.2019.10.24.09.27.50 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Oct 2019 09:27:51 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 20/51] target/arm: Rebuild hflags at CPSR writes Date: Thu, 24 Oct 2019 17:26:53 +0100 Message-Id: <20191024162724.31675-21-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191024162724.31675-1-peter.maydell@linaro.org> References: <20191024162724.31675-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 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson Continue setting, but not relying upon, env->hflags. Reviewed-by: Alex Bennée Signed-off-by: Richard Henderson Message-id: 20191023150057.25731-19-richard.henderson@linaro.org Signed-off-by: Peter Maydell --- target/arm/op_helper.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/target/arm/op_helper.c b/target/arm/op_helper.c index ccc2cecb467..b529d6c1bf7 100644 --- a/target/arm/op_helper.c +++ b/target/arm/op_helper.c @@ -224,6 +224,7 @@ uint32_t HELPER(usat16)(CPUARMState *env, uint32_t x, uint32_t shift) void HELPER(setend)(CPUARMState *env) { env->uncached_cpsr ^= CPSR_E; + arm_rebuild_hflags(env); } /* Function checks whether WFx (WFI/WFE) instructions are set up to be trapped. @@ -387,6 +388,8 @@ uint32_t HELPER(cpsr_read)(CPUARMState *env) void HELPER(cpsr_write)(CPUARMState *env, uint32_t val, uint32_t mask) { cpsr_write(env, val, mask, CPSRWriteByInstr); + /* TODO: Not all cpsr bits are relevant to hflags. */ + arm_rebuild_hflags(env); } /* Write the CPSR for a 32-bit exception return */ From patchwork Thu Oct 24 16:26:54 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 11210339 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 938F914E5 for ; Thu, 24 Oct 2019 16:55:18 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 692C0205C9 for ; Thu, 24 Oct 2019 16:55:18 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="FvlpS+bp" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 692C0205C9 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:48086 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNgOL-00070w-6Z for patchwork-qemu-devel@patchwork.kernel.org; Thu, 24 Oct 2019 12:55:17 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57955) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNfxt-0007YF-BX for qemu-devel@nongnu.org; Thu, 24 Oct 2019 12:27:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iNfxr-0000qB-0H for qemu-devel@nongnu.org; Thu, 24 Oct 2019 12:27:57 -0400 Received: from mail-wm1-x342.google.com ([2a00:1450:4864:20::342]:40265) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iNfxq-0000pq-QM for qemu-devel@nongnu.org; Thu, 24 Oct 2019 12:27:54 -0400 Received: by mail-wm1-x342.google.com with SMTP id w9so2041310wmm.5 for ; Thu, 24 Oct 2019 09:27:54 -0700 (PDT) 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=WFUwsZ8ugMBSw4ZJiorvJWtT/rnVZy1+6h/U7Ubz84I=; b=FvlpS+bptjotcCUjpId8+EOAkiPi2lLIi++W0vtndEr+rR8s797acpZQ+qjW4LW5Ik 7qlbhU180njZNz1xLlsmwMxE7XToRmoZy2oht1zPwbf+UlhLB+l9kXa9rJkwLjd9oYjl byGR5/zw2kDZJBe0cIk2kEXFw/lYNxtYuNSPbLhe5gIZqcQgDljs4Wz1rvE1w5OHW/ZK yoM7H7HcEu3rGtGdqvaZYUw9bZ3QwgTbRP/1jUKh6LWHB0A2Atk7gSkuhr9p11cKDP44 s7DQQvmHEcaP+zzFzKq85nCHVHaWCmA6Z30ae0amaDsvjDNAs3MqvtlS/UXAlGWkg44p ZXhA== 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=WFUwsZ8ugMBSw4ZJiorvJWtT/rnVZy1+6h/U7Ubz84I=; b=ctPSe7hB/OabZF6PR4khgI7W0uFhbZ71nzkUQrVNTDgw1Afm0lM3Bkj9N7Er8IWChL B3QhAE29RDVZwQyo2MXqlkUL4o0r+/PezmGkZOvAs9p6mbiGQlhYFac7cytLh5ay75oK DrBcft8Sj53DXh9z13IabjxIE83RX4W1Tx6UQYOBXS7upsTPmF7RRGQfhql3KUjnG2TY ksPN4uBnZe1a/pQvbQDK+7lTHbFI/zA3h4ZHZJ1ypgdWetmv5PoBCfslxf5cdD659OBG OUfAzSNw3VQPfmIol3V8DtUmW6d4tVPk1jAI0dJqAQVlEt7bsfsSCBLWLb4EV1MElQ9n yOgQ== X-Gm-Message-State: APjAAAV2FAo4QU2eiFlK0t0bFei9ugnTq4IwmzCLZCCfI3TQHmz1J5/E 0z88HVMSjwVQ4e54B+19n+RNRDoX5yw= X-Google-Smtp-Source: APXvYqxqL1ESrVS77gWrLuFCA+1FmHqRaR1shvunrDPRZeft/BEN+q8ai01O+tXaHKbMTFPyNSMT0w== X-Received: by 2002:a1c:7719:: with SMTP id t25mr5531511wmi.56.1571934473623; Thu, 24 Oct 2019 09:27:53 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id r27sm42606124wrc.55.2019.10.24.09.27.52 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Oct 2019 09:27:53 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 21/51] target/arm: Rebuild hflags at Xscale SCTLR writes Date: Thu, 24 Oct 2019 17:26:54 +0100 Message-Id: <20191024162724.31675-22-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191024162724.31675-1-peter.maydell@linaro.org> References: <20191024162724.31675-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::342 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson Continue setting, but not relying upon, env->hflags. Signed-off-by: Richard Henderson Message-id: 20191023150057.25731-20-richard.henderson@linaro.org Signed-off-by: Peter Maydell --- target/arm/helper.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/target/arm/helper.c b/target/arm/helper.c index aae7b62458f..c55783e5406 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -4174,6 +4174,16 @@ static void sctlr_write(CPUARMState *env, const ARMCPRegInfo *ri, /* ??? Lots of these bits are not implemented. */ /* This may enable/disable the MMU, so do a TLB flush. */ tlb_flush(CPU(cpu)); + + if (ri->type & ARM_CP_SUPPRESS_TB_END) { + /* + * Normally we would always end the TB on an SCTLR write; see the + * comment in ARMCPRegInfo sctlr initialization below for why Xscale + * is special. Setting ARM_CP_SUPPRESS_TB_END also stops the rebuild + * of hflags from the translator, so do it here. + */ + arm_rebuild_hflags(env); + } } static CPAccessResult fpexc32_access(CPUARMState *env, const ARMCPRegInfo *ri, From patchwork Thu Oct 24 16:26:55 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 11210357 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0AA5414E5 for ; Thu, 24 Oct 2019 16:59:00 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D40B9205C9 for ; Thu, 24 Oct 2019 16:58:59 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="dFin8SZe" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D40B9205C9 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:48155 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNgRu-0005U0-Rj for patchwork-qemu-devel@patchwork.kernel.org; Thu, 24 Oct 2019 12:58:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57975) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNfxu-0007aD-Ef for qemu-devel@nongnu.org; Thu, 24 Oct 2019 12:27:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iNfxt-0000r0-33 for qemu-devel@nongnu.org; Thu, 24 Oct 2019 12:27:58 -0400 Received: from mail-wm1-x330.google.com ([2a00:1450:4864:20::330]:35538) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iNfxr-0000qL-Sy for qemu-devel@nongnu.org; Thu, 24 Oct 2019 12:27:57 -0400 Received: by mail-wm1-x330.google.com with SMTP id v6so3231251wmj.0 for ; Thu, 24 Oct 2019 09:27:55 -0700 (PDT) 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=9fEeMZ9uPtcAifoblXjrkL5Kbv7QSQTtSjC/i1CHC68=; b=dFin8SZeX0EBItnbFV28EO9KDRWx+gs8o2T0sZkHUwvta+LqUaqdxM6mPtoQew6VBB l/heKWlVzWwkbVd7rwOnlcZebOUliUihfCmquo0SXq1gnkrD/Th9cJnRs9+7n3clLboy spIfAm9hYlhIcSBmQ0q7etGhMdV8TBv/3PAlyy7Fj6KCjNoFN4Ru0sJ3eDOqctgbeSWR UF3fxbpVVCfat0YeXh/4sNLgRD+8xyWm8w+GmLp+gKcofaaT+Irp+9CqZkesn8Wr63+f 29TIVMGZ4JGZLTbKUrAaGfNZdtcyGBUqXxDLJbKU4TtP3rdaKngQQ2Jbh/5xlkfm36V/ BA7Q== 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=9fEeMZ9uPtcAifoblXjrkL5Kbv7QSQTtSjC/i1CHC68=; b=d6moqV3FyUik+ALP0ZoR24X3eDWmakK5SDlyB4643GF4bZuW2jjUXfb4ccOF7w/kDw LGJL++m04TZnkus6DmoZTa2RzFUnTJWlOtsrioON/peePwygjoDfiwx0H6CuWXHXzMje UzhNweOYtmoqwtjGJABiu5M6hdmp/rG52j/cLNYX3SiBPofvxOw7QVaJ518Vur/x3KqD hfe46kLGzbBiPVtzZ9XmDqE35ypISjF2xy9lQOug5TqJ1CH0dkexmmPPex0d6nLwHpZS a3JIQeRKdDZAwuVUS2BuOARpMtvefoxBTawI/wD/ddeu0iAj2RLN2Hlz8kru3LVwEoKx T1+w== X-Gm-Message-State: APjAAAWyf62ZGPj9CLvoAuYX11KmrT/yqVYyFH+vZ9dcNgU51RIvqcu4 piGumdNf8XXcmO0jMfqclPyWaUa7gdA= X-Google-Smtp-Source: APXvYqx5IkEDI6iB7EEmJuq1ORfpvOgZkACmNw0H15pHar99ripxlMCG2VyO6uXqCyjAUmt2QVV2lw== X-Received: by 2002:a1c:1bcd:: with SMTP id b196mr5699960wmb.12.1571934474705; Thu, 24 Oct 2019 09:27:54 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id r27sm42606124wrc.55.2019.10.24.09.27.53 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Oct 2019 09:27:54 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 22/51] target/arm: Rebuild hflags for M-profile Date: Thu, 24 Oct 2019 17:26:55 +0100 Message-Id: <20191024162724.31675-23-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191024162724.31675-1-peter.maydell@linaro.org> References: <20191024162724.31675-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::330 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson Continue setting, but not relying upon, env->hflags. Reviewed-by: Alex Bennée Signed-off-by: Richard Henderson Message-id: 20191023150057.25731-21-richard.henderson@linaro.org Signed-off-by: Peter Maydell --- target/arm/m_helper.c | 6 ++++++ target/arm/translate.c | 5 ++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/target/arm/m_helper.c b/target/arm/m_helper.c index 27cd2f3f964..f2512e448e2 100644 --- a/target/arm/m_helper.c +++ b/target/arm/m_helper.c @@ -494,6 +494,7 @@ void HELPER(v7m_bxns)(CPUARMState *env, uint32_t dest) switch_v7m_security_state(env, dest & 1); env->thumb = 1; env->regs[15] = dest & ~1; + arm_rebuild_hflags(env); } void HELPER(v7m_blxns)(CPUARMState *env, uint32_t dest) @@ -555,6 +556,7 @@ void HELPER(v7m_blxns)(CPUARMState *env, uint32_t dest) switch_v7m_security_state(env, 0); env->thumb = 1; env->regs[15] = dest; + arm_rebuild_hflags(env); } static uint32_t *get_v7m_sp_ptr(CPUARMState *env, bool secure, bool threadmode, @@ -895,6 +897,7 @@ static void v7m_exception_taken(ARMCPU *cpu, uint32_t lr, bool dotailchain, env->regs[14] = lr; env->regs[15] = addr & 0xfffffffe; env->thumb = addr & 1; + arm_rebuild_hflags(env); } static void v7m_update_fpccr(CPUARMState *env, uint32_t frameptr, @@ -1765,6 +1768,7 @@ static void do_v7m_exception_exit(ARMCPU *cpu) /* Otherwise, we have a successful exception exit. */ arm_clear_exclusive(env); + arm_rebuild_hflags(env); qemu_log_mask(CPU_LOG_INT, "...successful exception return\n"); } @@ -1837,6 +1841,7 @@ static bool do_v7m_function_return(ARMCPU *cpu) xpsr_write(env, 0, XPSR_IT); env->thumb = newpc & 1; env->regs[15] = newpc & ~1; + arm_rebuild_hflags(env); qemu_log_mask(CPU_LOG_INT, "...function return successful\n"); return true; @@ -1959,6 +1964,7 @@ static bool v7m_handle_execute_nsc(ARMCPU *cpu) switch_v7m_security_state(env, true); xpsr_write(env, 0, XPSR_IT); env->regs[15] += 4; + arm_rebuild_hflags(env); return true; gen_invep: diff --git a/target/arm/translate.c b/target/arm/translate.c index 46a0bf51c95..2ea9da7637b 100644 --- a/target/arm/translate.c +++ b/target/arm/translate.c @@ -8327,7 +8327,7 @@ static bool trans_MRS_v7m(DisasContext *s, arg_MRS_v7m *a) static bool trans_MSR_v7m(DisasContext *s, arg_MSR_v7m *a) { - TCGv_i32 addr, reg; + TCGv_i32 addr, reg, el; if (!arm_dc_feature(s, ARM_FEATURE_M)) { return false; @@ -8337,6 +8337,9 @@ static bool trans_MSR_v7m(DisasContext *s, arg_MSR_v7m *a) gen_helper_v7m_msr(cpu_env, addr, reg); tcg_temp_free_i32(addr); tcg_temp_free_i32(reg); + el = tcg_const_i32(s->current_el); + gen_helper_rebuild_hflags_m32(cpu_env, el); + tcg_temp_free_i32(el); gen_lookup_tb(s); return true; } From patchwork Thu Oct 24 16:26:56 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 11210365 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 140A81575 for ; Thu, 24 Oct 2019 17:02:59 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id DCB5620650 for ; Thu, 24 Oct 2019 17:02:58 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="rcKcYb4Q" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DCB5620650 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:48224 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNgVl-00025d-JZ for patchwork-qemu-devel@patchwork.kernel.org; Thu, 24 Oct 2019 13:02:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57986) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNfxv-0007cI-MP for qemu-devel@nongnu.org; Thu, 24 Oct 2019 12:28:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iNfxt-0000rI-Dl for qemu-devel@nongnu.org; Thu, 24 Oct 2019 12:27:58 -0400 Received: from mail-wm1-x341.google.com ([2a00:1450:4864:20::341]:39153) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iNfxt-0000qo-7a for qemu-devel@nongnu.org; Thu, 24 Oct 2019 12:27:57 -0400 Received: by mail-wm1-x341.google.com with SMTP id r141so3206480wme.4 for ; Thu, 24 Oct 2019 09:27:57 -0700 (PDT) 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=AY2/tIXkLZV7yrWE3pOZo6OjdcTvWP16EPP+NMcPWOY=; b=rcKcYb4Q/C6aJJS7RCxWq/1+9rYHncrV6q41sNHFI/21mW++j72hExwaa4beHA0AA3 Gu/SbVrRB4T983waVo533cEl0BSpGEQlDk6I/D2vAaTMmo/evCpadKor5vYzVsD+ybRA 5cVsEafLhmYPQZsineSASfQiodZVhWCWHZZhD78TEnuY1ioY9d3pai5e64MwqA0UorLN a98YK5giwQf+3q+MHRWdttSvg6PMvGuHAjQkrrY9VGyX/LufVwxnk0+lUaJQT8CG5wSk RH9oYavr+37dRDiTQqS724yGmZfeJE8SydO9ey4shwVZI5CHsNJgms9lNTO4v+pjIt47 l2Dg== 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=AY2/tIXkLZV7yrWE3pOZo6OjdcTvWP16EPP+NMcPWOY=; b=GLXAPiEunqo6QTx7gf7zY3iX6oWfzmZrfcOsXgzK7eybwxlFPhPYdYqGNkrleYMQHy 29TRDfoYe720z7VppAp0t5WHcogUC2RtP17rwbBjwgzv3Y1k+2hixaSIIwD26roQQ2tr /B/A39Tv9QhlfScrxWzeSIDS5NsdQAqnjeMp0H8V1WRbzWpiQBv1IHQhhatg7Aick1vs e9cQ5rl7gpn+5LBgAsVV8V1oeDl9UnnVidgGiomzgDeKCnFeOuKbdp+cXAD8vJ3mca5F qFCHVjvwgrnQbp/Rl4cuNsxXFgt0gz8dyjzJ9rhgTe9bjLEfxQ71KQ3P5bDc1e7oV8/i Qhmg== X-Gm-Message-State: APjAAAWupHZm1ExQ4JHA5d29Dh8uCIV64t035Z9yH6r1LGi3j3YYZSRY OMJh2dBbbY+uuOPoi82TouZ3N50ryQk= X-Google-Smtp-Source: APXvYqwCXIgrKooOxhOXVjcGh/+VvflhVDg+EFPTi4pljyMlERcPGVrKypgba3h22dIg3fnvTZJlGA== X-Received: by 2002:a1c:39c1:: with SMTP id g184mr5688761wma.75.1571934475889; Thu, 24 Oct 2019 09:27:55 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id r27sm42606124wrc.55.2019.10.24.09.27.54 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Oct 2019 09:27:55 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 23/51] target/arm: Rebuild hflags for M-profile NVIC Date: Thu, 24 Oct 2019 17:26:56 +0100 Message-Id: <20191024162724.31675-24-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191024162724.31675-1-peter.maydell@linaro.org> References: <20191024162724.31675-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::341 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson Continue setting, but not relying upon, env->hflags. Suggested-by: Peter Maydell Signed-off-by: Richard Henderson Message-id: 20191023150057.25731-22-richard.henderson@linaro.org Signed-off-by: Peter Maydell --- hw/intc/armv7m_nvic.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/hw/intc/armv7m_nvic.c b/hw/intc/armv7m_nvic.c index 8e93e51e815..e8c74f9ebaf 100644 --- a/hw/intc/armv7m_nvic.c +++ b/hw/intc/armv7m_nvic.c @@ -2251,7 +2251,7 @@ static MemTxResult nvic_sysreg_write(void *opaque, hwaddr addr, } } nvic_irq_update(s); - return MEMTX_OK; + goto exit_ok; case 0x200 ... 0x23f: /* NVIC Set pend */ /* the special logic in armv7m_nvic_set_pending() * is not needed since IRQs are never escalated @@ -2269,9 +2269,9 @@ static MemTxResult nvic_sysreg_write(void *opaque, hwaddr addr, } } nvic_irq_update(s); - return MEMTX_OK; + goto exit_ok; case 0x300 ... 0x33f: /* NVIC Active */ - return MEMTX_OK; /* R/O */ + goto exit_ok; /* R/O */ case 0x400 ... 0x5ef: /* NVIC Priority */ startvec = (offset - 0x400) + NVIC_FIRST_IRQ; /* vector # */ @@ -2281,10 +2281,10 @@ static MemTxResult nvic_sysreg_write(void *opaque, hwaddr addr, } } nvic_irq_update(s); - return MEMTX_OK; + goto exit_ok; case 0xd18 ... 0xd1b: /* System Handler Priority (SHPR1) */ if (!arm_feature(&s->cpu->env, ARM_FEATURE_M_MAIN)) { - return MEMTX_OK; + goto exit_ok; } /* fall through */ case 0xd1c ... 0xd23: /* System Handler Priority (SHPR2, SHPR3) */ @@ -2299,10 +2299,10 @@ static MemTxResult nvic_sysreg_write(void *opaque, hwaddr addr, set_prio(s, hdlidx, sbank, newprio); } nvic_irq_update(s); - return MEMTX_OK; + goto exit_ok; case 0xd28 ... 0xd2b: /* Configurable Fault Status (CFSR) */ if (!arm_feature(&s->cpu->env, ARM_FEATURE_M_MAIN)) { - return MEMTX_OK; + goto exit_ok; } /* All bits are W1C, so construct 32 bit value with 0s in * the parts not written by the access size @@ -2322,15 +2322,19 @@ static MemTxResult nvic_sysreg_write(void *opaque, hwaddr addr, */ s->cpu->env.v7m.cfsr[M_REG_NS] &= ~(value & R_V7M_CFSR_BFSR_MASK); } - return MEMTX_OK; + goto exit_ok; } if (size == 4) { nvic_writel(s, offset, value, attrs); - return MEMTX_OK; + goto exit_ok; } qemu_log_mask(LOG_GUEST_ERROR, "NVIC: Bad write of size %d at offset 0x%x\n", size, offset); /* This is UNPREDICTABLE; treat as RAZ/WI */ + + exit_ok: + /* Ensure any changes made are reflected in the cached hflags. */ + arm_rebuild_hflags(&s->cpu->env); return MEMTX_OK; } From patchwork Thu Oct 24 16:26:57 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 11210355 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6767D14E5 for ; Thu, 24 Oct 2019 16:58:03 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 3BE71205C9 for ; Thu, 24 Oct 2019 16:58:03 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="GGNv6wHw" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3BE71205C9 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:48140 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNgR0-0003n2-1U for patchwork-qemu-devel@patchwork.kernel.org; Thu, 24 Oct 2019 12:58:02 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57999) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNfxw-0007do-E2 for qemu-devel@nongnu.org; Thu, 24 Oct 2019 12:28:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iNfxu-0000rY-CE for qemu-devel@nongnu.org; Thu, 24 Oct 2019 12:28:00 -0400 Received: from mail-wm1-x330.google.com ([2a00:1450:4864:20::330]:33457) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iNfxu-0000rM-63 for qemu-devel@nongnu.org; Thu, 24 Oct 2019 12:27:58 -0400 Received: by mail-wm1-x330.google.com with SMTP id 6so2365001wmf.0 for ; Thu, 24 Oct 2019 09:27:58 -0700 (PDT) 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=hoD3aqwz/kF2U/X48pwyEPkA/UK/DENbEy2Cn4bAuH4=; b=GGNv6wHwfTL1QGLGhWzRJa+KjstPTyhmRqBkFGLxoGio2SZHiN+Ztf4zEC30C4/opi XguljHlgb6lOVuAbcNAlVhrx+kSzMwAQZSW7epW7HYOzZ9WwUnDSlxuCxKFlLjF/262V 9qnL579UohCTn2F0xQ/SHaDgOt5B6VxpnKHwSTIkd5C0jh6WMezd0HTiHHht0D5pF1JV BstneN31cXQliFkknfvmuoeBeSp31nwo7u2j0B7GQbynyhGqTrkwkkRw/wrnaLnA0Yor XBqSZnblJQNPnJiod6g7UcUIcuKmJ8ZNSfnYkP8DRnbG/uJ5dPHYWK0+rMC0JPelaCU8 B+qg== 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=hoD3aqwz/kF2U/X48pwyEPkA/UK/DENbEy2Cn4bAuH4=; b=spCCN0zFHiN1W+fjTcvYD+/Rx+FRy24c4knoZEWRHX+Hohg7adxwVb0PtlYPADPevL tzSp+0tOtgX5ELVlelgp1FkUTrMc79t7deL+5kqsYGQJFIoDA+gAEd7sFNr4+z65F0Ie hO0hAMKnPVivHaoZWB9QgjRO4QOO06N6q0Mq2PIeXAx4FfmvMjEzJKwF7/CfoS3d5CoI ARyeEM8IFHo3lBpzzewoEQLlgfz+/6S+LMKEf3s5C1qzmIjWdutcUAyKsUMorZb9jl9l 5jfSaBXhb+Lj74FY/Oun0KPyQLkVYf+rlyvPWgtgHjJtmVc69LGbPGR/oQu6sewqQAXj vidA== X-Gm-Message-State: APjAAAWp18pNk594J1rKDEmb4XFkhbZR9yZvHrNPPkgThI0SV5ZX/SC2 PJCHBpKLFuTdArfGls7Tj/ak+zEeMKo= X-Google-Smtp-Source: APXvYqxbUr4ZBsvf/NW23DQ44ke+h+5zFD+f+JK5Bn7KuztJ6w/jzLbaYVgbvzcRBiw7yywIih5vuQ== X-Received: by 2002:a1c:6a05:: with SMTP id f5mr5626959wmc.121.1571934477039; Thu, 24 Oct 2019 09:27:57 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id r27sm42606124wrc.55.2019.10.24.09.27.55 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Oct 2019 09:27:56 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 24/51] linux-user/aarch64: Rebuild hflags for TARGET_WORDS_BIGENDIAN Date: Thu, 24 Oct 2019 17:26:57 +0100 Message-Id: <20191024162724.31675-25-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191024162724.31675-1-peter.maydell@linaro.org> References: <20191024162724.31675-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::330 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson Continue setting, but not relying upon, env->hflags. Signed-off-by: Richard Henderson Message-id: 20191023150057.25731-23-richard.henderson@linaro.org Reviewed-by: Peter Maydell Signed-off-by: Peter Maydell --- linux-user/aarch64/cpu_loop.c | 1 + 1 file changed, 1 insertion(+) diff --git a/linux-user/aarch64/cpu_loop.c b/linux-user/aarch64/cpu_loop.c index 1295fa85313..31c845a70d4 100644 --- a/linux-user/aarch64/cpu_loop.c +++ b/linux-user/aarch64/cpu_loop.c @@ -173,6 +173,7 @@ void target_cpu_copy_regs(CPUArchState *env, struct target_pt_regs *regs) for (i = 1; i < 4; ++i) { env->cp15.sctlr_el[i] |= SCTLR_EE; } + arm_rebuild_hflags(env); #endif if (cpu_isar_feature(aa64_pauth, cpu)) { From patchwork Thu Oct 24 16:26:58 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 11210475 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B763F112C for ; Thu, 24 Oct 2019 17:13:47 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 8CBC420650 for ; Thu, 24 Oct 2019 17:13:47 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="TmwUmvea" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8CBC420650 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:48424 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNggE-0000AU-0i for patchwork-qemu-devel@patchwork.kernel.org; Thu, 24 Oct 2019 13:13:46 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58006) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNfxw-0007eK-Oi for qemu-devel@nongnu.org; Thu, 24 Oct 2019 12:28:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iNfxv-0000s3-KV for qemu-devel@nongnu.org; Thu, 24 Oct 2019 12:28:00 -0400 Received: from mail-wr1-x436.google.com ([2a00:1450:4864:20::436]:40424) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iNfxv-0000rs-EE for qemu-devel@nongnu.org; Thu, 24 Oct 2019 12:27:59 -0400 Received: by mail-wr1-x436.google.com with SMTP id o28so26784351wro.7 for ; Thu, 24 Oct 2019 09:27:59 -0700 (PDT) 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=acyYv45nXPHhkUzRU5weWk65uHswNK+60vD7SN3aiY4=; b=TmwUmveauFgZfmst5Mk7pRIQjwpBmB8XuGz/9gH8s3AFoYOIxPRAfitCL0jFnkLDv3 7RKgH6Nb4cCmD3O+bksDuGNoqMIg7Qmo1734Edsi1cKBvW+xavEib34hfIKRgtnxgOKw hGKPsv1zHl4JgXY422T/iEvCTLYGxq8QozTB9Cv+vhwBn4qMq0CRnFLlQDGaH7Yth7nH Ij1TMwhhtlDhdwC40PBOYktg7eIJXnN7nWjzp2Lx+PKK3vzxpDgOPPhxeMSATWvqcydu kHydFuhq4FyHm1xYTG5o0+RyNEfzJsNLDI5wyLfNHHN+p8GAxvTXyp0x5Kb4KBygcJXW BlkA== 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=acyYv45nXPHhkUzRU5weWk65uHswNK+60vD7SN3aiY4=; b=rWH/ZOVWqbeImDs1QuwFemCai08GJNhlxn7BzgEJGwDPXbqdo2pyMFIousy8oUV+qk 6d996zxgBC9Pm8E+ZHrk/vI2FzZBUiXeXgKmzcCM/R/83jOk76rK4EwRrf21IBcNXlDg yHH7G2ghnzBgK/fHSxjFMQ+On0tRWteiya/TWECNY9wIk4OTZaRugxxisEq6MTDcV63o 7GaFbx0bVjeSYsLGiQD2iiHf8R3EAbtGJBayKls7TdPDlQq5ZxEyMv/JgbRnEOH5bKqV er8igsjZAx7suXtktfsS5PHPNy1pBEogApRP/XnKe6tEMEY5T3l0fHEYHjMBkdGL2nH2 zHiw== X-Gm-Message-State: APjAAAVs9L+crEzxVR+TY7plOI6vMtontYmGoLeGlBtHeZqmDsCkBZTM syp5Rwh/jIxx5m1mF3B67RVunKSSlp8= X-Google-Smtp-Source: APXvYqzBVXnOw+A56LybEnsvJ/nv23IpfI9C5QNjufGeYrsuqOVFfy/KHLlg/Md6TY/BJM+Q85c7Wg== X-Received: by 2002:adf:8289:: with SMTP id 9mr4946098wrc.0.1571934478172; Thu, 24 Oct 2019 09:27:58 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id r27sm42606124wrc.55.2019.10.24.09.27.57 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Oct 2019 09:27:57 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 25/51] linux-user/arm: Rebuild hflags for TARGET_WORDS_BIGENDIAN Date: Thu, 24 Oct 2019 17:26:58 +0100 Message-Id: <20191024162724.31675-26-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191024162724.31675-1-peter.maydell@linaro.org> References: <20191024162724.31675-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 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson Continue setting, but not relying upon, env->hflags. Signed-off-by: Richard Henderson Message-id: 20191023150057.25731-24-richard.henderson@linaro.org Reviewed-by: Peter Maydell Signed-off-by: Peter Maydell --- linux-user/arm/cpu_loop.c | 1 + 1 file changed, 1 insertion(+) diff --git a/linux-user/arm/cpu_loop.c b/linux-user/arm/cpu_loop.c index e28c45cd4ab..7be40717518 100644 --- a/linux-user/arm/cpu_loop.c +++ b/linux-user/arm/cpu_loop.c @@ -440,6 +440,7 @@ void target_cpu_copy_regs(CPUArchState *env, struct target_pt_regs *regs) } else { env->cp15.sctlr_el[1] |= SCTLR_B; } + arm_rebuild_hflags(env); #endif ts->stack_base = info->start_stack; From patchwork Thu Oct 24 16:26:59 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 11210363 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id ED91414E5 for ; Thu, 24 Oct 2019 17:01:33 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id C38CF20650 for ; Thu, 24 Oct 2019 17:01:33 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="L2PlupZG" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C38CF20650 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:48204 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNgUO-0000UP-Bd for patchwork-qemu-devel@patchwork.kernel.org; Thu, 24 Oct 2019 13:01:32 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58030) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNfxy-0007hP-D6 for qemu-devel@nongnu.org; Thu, 24 Oct 2019 12:28:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iNfxw-0000si-P4 for qemu-devel@nongnu.org; Thu, 24 Oct 2019 12:28:02 -0400 Received: from mail-wr1-x442.google.com ([2a00:1450:4864:20::442]:46810) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iNfxw-0000sC-I7 for qemu-devel@nongnu.org; Thu, 24 Oct 2019 12:28:00 -0400 Received: by mail-wr1-x442.google.com with SMTP id n15so16009646wrw.13 for ; Thu, 24 Oct 2019 09:28:00 -0700 (PDT) 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=EcerNk3YeDT5sQSP3taUcz8aA1kUh9D2O9nEmkTp88Q=; b=L2PlupZGCsVM1GVSZCQM9wCd35aNupZyY2spI6UcISexUjjl8KPSUKoW5S+jv2iwOt bdTpsbx1iZ1eW+ZF0jWCBFmAZt5Yrsu7yYuUu786/mybqOMSMMhz+gmabKwiuR3cUpk+ eQwNS0K89OtvMPRGx0TYh8J9ddvuxa4SBNdJNgPEPjYD3Hffr4ri0nzociiyKaLSMUZr 1Ziabd+5F+27gaeczKMC6r/Jg0EpIRuo7m5sWzut06l72yBF3Wd7dcaokbSiSwacknI+ WLA00aEeRFzAy+wrhLn5UMZKR+oiKBAan21lrqLgXWcMRbc7bVm5VUCtqUWDa+CXZ3bi QhLQ== 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=EcerNk3YeDT5sQSP3taUcz8aA1kUh9D2O9nEmkTp88Q=; b=f4NofocNo+aGKWL6ytVRVNtVTHDxcF0egA5sqIJLlLX8A8datdDKmz8MUwsH2CwRlS 21HmRHRflQetdRahshv4GCcacRb7/CdrMZM1MzPaVXlE0uUtcoke0tcZVpUCl0qHzJay rebyl2DWUl9LkZp+roxDBzqKcm7uvZ0bUBcv132u1HoDY2+z3phsuDkPQKAs7pmxi+6C J8c4tYITeq5NoaW4vXIOL1chV5P/BlpmDD9oEMj93FfLN/YZ9Zkyh5LmxESXgHsSSrlM c+U2ZIx+IDKpRs8pKQPJj/2oMIA97G+6cQGRc1hUjNyZ0KZ3Cq12mOcwDwvsjxy3gLpe BXGg== X-Gm-Message-State: APjAAAWWrdADJkQgek15drZxaFSugha+T0opDBPja3Hu7WWmqfVtM1bZ BEuQfCe2ZeS1LCohIGQxTl8vunBZSoA= X-Google-Smtp-Source: APXvYqwJ2ATksEuP6UHrnf1xcQPw18vUI7YHW0iXQM/7he4xlEs9ndiPv7ZR4/wknyzdr1as4sZLTA== X-Received: by 2002:adf:f5cc:: with SMTP id k12mr4556905wrp.65.1571934479240; Thu, 24 Oct 2019 09:27:59 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id r27sm42606124wrc.55.2019.10.24.09.27.58 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Oct 2019 09:27:58 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 26/51] target/arm: Rely on hflags correct in cpu_get_tb_cpu_state Date: Thu, 24 Oct 2019 17:26:59 +0100 Message-Id: <20191024162724.31675-27-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191024162724.31675-1-peter.maydell@linaro.org> References: <20191024162724.31675-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 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson This is the payoff. From perf record -g data of ubuntu 18 boot and shutdown: BEFORE: - 23.02% 2.82% qemu-system-aar [.] helper_lookup_tb_ptr - 20.22% helper_lookup_tb_ptr + 10.05% tb_htable_lookup - 9.13% cpu_get_tb_cpu_state 3.20% aa64_va_parameters_both 0.55% fp_exception_el - 11.66% 4.74% qemu-system-aar [.] cpu_get_tb_cpu_state - 6.96% cpu_get_tb_cpu_state 3.63% aa64_va_parameters_both 0.60% fp_exception_el 0.53% sve_exception_el AFTER: - 16.40% 3.40% qemu-system-aar [.] helper_lookup_tb_ptr - 13.03% helper_lookup_tb_ptr + 11.19% tb_htable_lookup 0.55% cpu_get_tb_cpu_state 0.98% 0.71% qemu-system-aar [.] cpu_get_tb_cpu_state 0.87% 0.24% qemu-system-aar [.] rebuild_hflags_a64 Before, helper_lookup_tb_ptr is the second hottest function in the application, consuming almost a quarter of the runtime. Within the entire execution, cpu_get_tb_cpu_state consumes about 12%. After, helper_lookup_tb_ptr has dropped to the fourth hottest function, with consumption dropping to a sixth of the runtime. Within the entire execution, cpu_get_tb_cpu_state has dropped below 1%, and the supporting function to rebuild hflags also consumes about 1%. Assertions are retained for --enable-debug-tcg. Tested-by: Alex Bennée Reviewed-by: Alex Bennée Signed-off-by: Richard Henderson Message-id: 20191023150057.25731-25-richard.henderson@linaro.org Signed-off-by: Peter Maydell --- target/arm/helper.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/target/arm/helper.c b/target/arm/helper.c index c55783e5406..63815fc4cfc 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -11259,12 +11259,15 @@ void HELPER(rebuild_hflags_a64)(CPUARMState *env, int el) void cpu_get_tb_cpu_state(CPUARMState *env, target_ulong *pc, target_ulong *cs_base, uint32_t *pflags) { - uint32_t flags, pstate_for_ss; + uint32_t flags = env->hflags; + uint32_t pstate_for_ss; *cs_base = 0; - flags = rebuild_hflags_internal(env); +#ifdef CONFIG_DEBUG_TCG + assert(flags == rebuild_hflags_internal(env)); +#endif - if (is_a64(env)) { + if (FIELD_EX32(flags, TBFLAG_ANY, AARCH64_STATE)) { *pc = env->pc; if (cpu_isar_feature(aa64_bti, env_archcpu(env))) { flags = FIELD_DP32(flags, TBFLAG_A64, BTYPE, env->btype); From patchwork Thu Oct 24 16:27:00 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 11210381 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 35E92112C for ; Thu, 24 Oct 2019 17:05:38 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 0C05F21906 for ; Thu, 24 Oct 2019 17:05:37 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="YGAt38FM" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0C05F21906 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:48272 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNgYJ-0008ED-NE for patchwork-qemu-devel@patchwork.kernel.org; Thu, 24 Oct 2019 13:05:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58041) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNfxz-0007io-0y for qemu-devel@nongnu.org; Thu, 24 Oct 2019 12:28:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iNfxx-0000tL-PU for qemu-devel@nongnu.org; Thu, 24 Oct 2019 12:28:02 -0400 Received: from mail-wm1-x335.google.com ([2a00:1450:4864:20::335]:53657) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iNfxx-0000so-JP for qemu-devel@nongnu.org; Thu, 24 Oct 2019 12:28:01 -0400 Received: by mail-wm1-x335.google.com with SMTP id n7so2717854wmc.3 for ; Thu, 24 Oct 2019 09:28:01 -0700 (PDT) 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=uYiMMG2g4SkvD83lkxSsHqqS6mTu3zs23wVOsym/Wvk=; b=YGAt38FM7o8oUVR59UnnmmzkbFzAmnaIZxnUBJH6VKo1MzNxRxOTdY67M90w5P81cx JEa5pRgnv+YsIWkf6q4kRzDZrEhvetjMaYgwtVleJS6g3dSq6NUNJ8PbqKowh45oFBDZ Y8Ss6n4xbbwRiWm7cuMnX1L5gewDcVtdp1kVfg9hohP2+fgmm/AbDF/980hN/GkVQIPb xK6mk9JS+nZNeIhbq727+wgIgP7Ghl3M630OrlwsS/8g13Fj1uhpIyNSVB1J5Ki/IMpf VInc2J/nXEuHwagAht0th5U0jIFQmv64NnAPgO4xrsR74rZStfyznJzy55/AUq3QED8T SXPA== 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=uYiMMG2g4SkvD83lkxSsHqqS6mTu3zs23wVOsym/Wvk=; b=qUJ7qBQo5eZZcMELbO/yZcH//ik+zBPtFIKtvlHZmz3psSLQLpXXgD5wRplD9VC/gB SRU2S7myNFl3PSoibWMYNSnKl8kjkjyxJzdt3yhEZfjk5J+n52eziTZSOV0gCDziOVfx RnuMjHaZFeJeA9OXRrBKwCgXplXOONGJzV1tFC+a61K1GDBCt60JuhS/RUWiBuNTtLfJ qA5R1o+tudn0DbKoEHB6daH1Sn1GeI1tb/SAcgCO509PW6nyOzRYh8qMnaiwrcUgwRLe 3Lt1pWKsIi/2RDBmUkP/2D+Avuaru1ud8RYCTXUZWDHrTOQOOWKAjGwm9KCbt52UCYMh gmJw== X-Gm-Message-State: APjAAAV5eO8R7c0zW0EhQzF4L6ycEecNFSyLEM6Z+N0FEmohLd5nFoPl S5zWhX0em8R3lNOUGPqa7oTvQti2s7A= X-Google-Smtp-Source: APXvYqwOuOVyn7fGOM9kiTDjzA30LaLrk2WOvQP0ieRp0MbiRWoQ8MqE+mjgDiTTvqEwDYJxRFGHrQ== X-Received: by 2002:a05:600c:2056:: with SMTP id p22mr5677498wmg.44.1571934480301; Thu, 24 Oct 2019 09:28:00 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id r27sm42606124wrc.55.2019.10.24.09.27.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Oct 2019 09:27:59 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 27/51] hw/net/fsl_etsec/etsec.c: Switch to transaction-based ptimer API Date: Thu, 24 Oct 2019 17:27:00 +0100 Message-Id: <20191024162724.31675-28-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191024162724.31675-1-peter.maydell@linaro.org> References: <20191024162724.31675-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::335 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" Switch the fsl_etsec code away from bottom-half based ptimers to the new transaction-based ptimer API. This just requires adding begin/commit calls around the various places that modify the ptimer state, and using the new ptimer_init() function to create the timer. Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Alistair Francis Message-id: 20191017132122.4402-2-peter.maydell@linaro.org Signed-off-by: Peter Maydell --- hw/net/fsl_etsec/etsec.h | 1 - hw/net/fsl_etsec/etsec.c | 9 +++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/hw/net/fsl_etsec/etsec.h b/hw/net/fsl_etsec/etsec.h index 09d05c21338..7951c3ad65f 100644 --- a/hw/net/fsl_etsec/etsec.h +++ b/hw/net/fsl_etsec/etsec.h @@ -141,7 +141,6 @@ typedef struct eTSEC { uint16_t phy_control; /* Polling */ - QEMUBH *bh; struct ptimer_state *ptimer; /* Whether we should flush the rx queue when buffer becomes available. */ diff --git a/hw/net/fsl_etsec/etsec.c b/hw/net/fsl_etsec/etsec.c index d9b3e8c691e..717de76569a 100644 --- a/hw/net/fsl_etsec/etsec.c +++ b/hw/net/fsl_etsec/etsec.c @@ -34,7 +34,6 @@ #include "etsec.h" #include "registers.h" #include "qemu/log.h" -#include "qemu/main-loop.h" #include "qemu/module.h" /* #define HEX_DUMP */ @@ -195,9 +194,11 @@ static void write_dmactrl(eTSEC *etsec, if (!(value & DMACTRL_WOP)) { /* Start polling */ + ptimer_transaction_begin(etsec->ptimer); ptimer_stop(etsec->ptimer); ptimer_set_count(etsec->ptimer, 1); ptimer_run(etsec->ptimer, 1); + ptimer_transaction_commit(etsec->ptimer); } } @@ -391,10 +392,10 @@ static void etsec_realize(DeviceState *dev, Error **errp) object_get_typename(OBJECT(dev)), dev->id, etsec); qemu_format_nic_info_str(qemu_get_queue(etsec->nic), etsec->conf.macaddr.a); - - etsec->bh = qemu_bh_new(etsec_timer_hit, etsec); - etsec->ptimer = ptimer_init_with_bh(etsec->bh, PTIMER_POLICY_DEFAULT); + etsec->ptimer = ptimer_init(etsec_timer_hit, etsec, PTIMER_POLICY_DEFAULT); + ptimer_transaction_begin(etsec->ptimer); ptimer_set_freq(etsec->ptimer, 100); + ptimer_transaction_commit(etsec->ptimer); } static void etsec_instance_init(Object *obj) From patchwork Thu Oct 24 16:27:01 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 11210483 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 14D31139A for ; Thu, 24 Oct 2019 17:18:02 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id DF16820659 for ; Thu, 24 Oct 2019 17:18:01 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="tmCbLpdv" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DF16820659 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:48522 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNgkK-0001ic-9U for patchwork-qemu-devel@patchwork.kernel.org; Thu, 24 Oct 2019 13:18:00 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58057) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNfy0-0007ky-0u for qemu-devel@nongnu.org; Thu, 24 Oct 2019 12:28:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iNfxy-0000tp-RO for qemu-devel@nongnu.org; Thu, 24 Oct 2019 12:28:03 -0400 Received: from mail-wm1-x342.google.com ([2a00:1450:4864:20::342]:39155) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iNfxy-0000tU-Kx for qemu-devel@nongnu.org; Thu, 24 Oct 2019 12:28:02 -0400 Received: by mail-wm1-x342.google.com with SMTP id r141so3206741wme.4 for ; Thu, 24 Oct 2019 09:28:02 -0700 (PDT) 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=bZdsncuNDnJQ9EFbxxKEYZAYg/nM+O7WLjtwwmpCRgA=; b=tmCbLpdvCUOf21XT0hPElWB8zybl3kwItTk95krsoe+VzpYBuZInMRw4kEIeI5EpOD pBhU1TlZdrVIjtDnRwPMkgrmdgwznTeUqFrW/8Gq/sQNIfvzr0eR67X7mM59+sMG2mzW p0TuQOSu/iU/BGNFZuLVCFlj6IXntbuATuN/RuqoZsztPRdoCqYIH9vWpP4x0KDrQRQK SpQVHWcr/WH+Vg5Fl4/xpNzbiJ51rJORwm1Hilhzr9vXzin3R/MnCqJ2V0A2Udn+28GA 5muLIlurWpSH+dFTH3H5lNoNLcAbjsecsx91EOR4otnDCHdnZZzqfzFLMsgVngW1WRZ8 4DGw== 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=bZdsncuNDnJQ9EFbxxKEYZAYg/nM+O7WLjtwwmpCRgA=; b=YMoZowtzXRlnUTEZo7sIHaMAhYMxI/ttRgnSUIzxUyouFbHB77vW3fNI3fIbS2wPve q9NJDarBGmTkvFDOkeMSHMXfbVoZDeXq9I8Ld+Pk3BVKx3HQZrcvbNAcva3KkNU9yKIj 7vR2LBhLSw9tytNjqxspY5O4/U5lfpcyYGydu6pdAx+MZFTzE0O9bT0Cs8ckxoL0ZTxG jav29LqPvPaD53qfWrDgIJxC+TrWLqRiNn8OGnloA3MOJlf5YbTCCE+vXfdlE9z9mK3p lHBXNN+F4iMTEW2aw/oYzWV9GDU8awdxY7I5J0o3M6Iq6dfmMjloXWwSdSBnl//B9jIc jn+g== X-Gm-Message-State: APjAAAXdKpiULbzFBdfMxkA0H8gam5GTy/OJUBkYVpMf3J5iOqxykZF+ MtEyKXcmSqsUqXi6Yrx0G6wSEr4/yt0= X-Google-Smtp-Source: APXvYqxS5C72jo72kh980pRa6BteDh0onaFTPPPIvbNMValLtpYcAdGSl6aWtdK4e1RYnVBH8W/l3A== X-Received: by 2002:a1c:9d07:: with SMTP id g7mr5739692wme.53.1571934481299; Thu, 24 Oct 2019 09:28:01 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id r27sm42606124wrc.55.2019.10.24.09.28.00 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Oct 2019 09:28:00 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 28/51] hw/timer/xilinx_timer.c: Switch to transaction-based ptimer API Date: Thu, 24 Oct 2019 17:27:01 +0100 Message-Id: <20191024162724.31675-29-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191024162724.31675-1-peter.maydell@linaro.org> References: <20191024162724.31675-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::342 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" Switch the xilinx_timer code away from bottom-half based ptimers to the new transaction-based ptimer API. This just requires adding begin/commit calls around the various places that modify the ptimer state, and using the new ptimer_init() function to create the timer. Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Alistair Francis Message-id: 20191017132122.4402-3-peter.maydell@linaro.org Signed-off-by: Peter Maydell --- hw/timer/xilinx_timer.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/hw/timer/xilinx_timer.c b/hw/timer/xilinx_timer.c index 92dbff304d9..7191ea54f58 100644 --- a/hw/timer/xilinx_timer.c +++ b/hw/timer/xilinx_timer.c @@ -28,7 +28,6 @@ #include "hw/ptimer.h" #include "hw/qdev-properties.h" #include "qemu/log.h" -#include "qemu/main-loop.h" #include "qemu/module.h" #define D(x) @@ -52,7 +51,6 @@ struct xlx_timer { - QEMUBH *bh; ptimer_state *ptimer; void *parent; int nr; /* for debug. */ @@ -134,6 +132,7 @@ timer_read(void *opaque, hwaddr addr, unsigned int size) return r; } +/* Must be called inside ptimer transaction block */ static void timer_enable(struct xlx_timer *xt) { uint64_t count; @@ -174,8 +173,11 @@ timer_write(void *opaque, hwaddr addr, value &= ~TCSR_TINT; xt->regs[addr] = value & 0x7ff; - if (value & TCSR_ENT) + if (value & TCSR_ENT) { + ptimer_transaction_begin(xt->ptimer); timer_enable(xt); + ptimer_transaction_commit(xt->ptimer); + } break; default: @@ -220,9 +222,10 @@ static void xilinx_timer_realize(DeviceState *dev, Error **errp) xt->parent = t; xt->nr = i; - xt->bh = qemu_bh_new(timer_hit, xt); - xt->ptimer = ptimer_init_with_bh(xt->bh, PTIMER_POLICY_DEFAULT); + xt->ptimer = ptimer_init(timer_hit, xt, PTIMER_POLICY_DEFAULT); + ptimer_transaction_begin(xt->ptimer); ptimer_set_freq(xt->ptimer, t->freq_hz); + ptimer_transaction_commit(xt->ptimer); } memory_region_init_io(&t->mmio, OBJECT(t), &timer_ops, t, "xlnx.xps-timer", From patchwork Thu Oct 24 16:27:02 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 11210371 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5BD601864 for ; Thu, 24 Oct 2019 17:04:52 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 3214420650 for ; Thu, 24 Oct 2019 17:04:52 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="ObZ5vpZH" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3214420650 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:48260 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNgXa-0006j4-Qc for patchwork-qemu-devel@patchwork.kernel.org; Thu, 24 Oct 2019 13:04:50 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58074) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNfy1-0007n9-6h for qemu-devel@nongnu.org; Thu, 24 Oct 2019 12:28:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iNfxz-0000uI-W5 for qemu-devel@nongnu.org; Thu, 24 Oct 2019 12:28:05 -0400 Received: from mail-wr1-x441.google.com ([2a00:1450:4864:20::441]:38091) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iNfxz-0000u0-Pq for qemu-devel@nongnu.org; Thu, 24 Oct 2019 12:28:03 -0400 Received: by mail-wr1-x441.google.com with SMTP id v9so15524429wrq.5 for ; Thu, 24 Oct 2019 09:28:03 -0700 (PDT) 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=WzfboK1OQbmWS+2qtK+sgT8HKfmWZJQr5eBbFKdwmAk=; b=ObZ5vpZH5jMOI0+is0hPadcaqMnr26G26JDvyQcxOHxwmG15qFm6GWPTy3nrDbxMkY FSLXY9bDlNm5G0f7Y8A//tRejZyeEt9Xaw6Qd6dOwkb1eZNVO8/jJpPucwrM1dSnbx2x KfPV+mPVMHNSjykh7Zlcts3eiHma9Lb5VZwqjCD/4TEsPelYb60o4gmgJ5OZtfAFDbWt IezzWLRTzXpESJmJrLx6U94/Yls/Zvc7Cznm3wMCXXMe8qAtzk+cIwRNyLQGBz58jr/A Amfc7QLl7wM9p9f5MY+UHS10pwmH03WShDXyyx2SrlXZ2pcuDtVEDgTWaLgK182CnRu0 HH3Q== 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=WzfboK1OQbmWS+2qtK+sgT8HKfmWZJQr5eBbFKdwmAk=; b=A4itcjiIDLWes3/daVFT+J5L/UTgr5JdjAuB9jChQtUYfB042OOAl5p4u3fHii/w9I pM3vWYu83ieDP4eaGYVNnKnhLdQ32W0PLvLTtXOwMf4jTk3rgikQ4/BXdOTQzDJjps5N 3HW3ikbCKSzKGgqmtNuAv7SCeXZla833guaucxBtaGCsPR0VK3wjH7LBOnCOiplRFQWg npNjb9uqsfsxLHIbMKFxQdZPY0BF3v4trhNi2L6UKOCbUZXkX+43Cx7vShhyg7aAi5OY uFmDgxuMUjP7jMBEQ2OMg1iSAs6vu+wUk60BfWPjhVPGLsLFgdAYOt2EiWDisRvqxisk tqyw== X-Gm-Message-State: APjAAAXQq9MWsCuq0MbK9MM+bkljelSlSqbftHuPJPeWv74OMHthLQPp NkEG9dkY1QCY/e05PjiFtfSUF6CLmvo= X-Google-Smtp-Source: APXvYqwT3Up8IOLkoitfPxxPsYknULgbOQS0O30IeseBO4A3m4lUKnhSx3yLQiqKNoxH2cdrBX9A6w== X-Received: by 2002:adf:ee4f:: with SMTP id w15mr4817276wro.378.1571934482385; Thu, 24 Oct 2019 09:28:02 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id r27sm42606124wrc.55.2019.10.24.09.28.01 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Oct 2019 09:28:01 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 29/51] hw/dma/xilinx_axidma.c: Switch to transaction-based ptimer API Date: Thu, 24 Oct 2019 17:27:02 +0100 Message-Id: <20191024162724.31675-30-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191024162724.31675-1-peter.maydell@linaro.org> References: <20191024162724.31675-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::441 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" Switch the xilinx_axidma code away from bottom-half based ptimers to the new transaction-based ptimer API. This just requires adding begin/commit calls around the various places that modify the ptimer state, and using the new ptimer_init() function to create the timer. Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Alistair Francis Message-id: 20191017132122.4402-4-peter.maydell@linaro.org Signed-off-by: Peter Maydell --- hw/dma/xilinx_axidma.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/hw/dma/xilinx_axidma.c b/hw/dma/xilinx_axidma.c index e035d1f7504..fb3a978e282 100644 --- a/hw/dma/xilinx_axidma.c +++ b/hw/dma/xilinx_axidma.c @@ -31,7 +31,6 @@ #include "hw/ptimer.h" #include "hw/qdev-properties.h" #include "qemu/log.h" -#include "qemu/main-loop.h" #include "qemu/module.h" #include "hw/stream.h" @@ -104,7 +103,6 @@ enum { }; struct Stream { - QEMUBH *bh; ptimer_state *ptimer; qemu_irq irq; @@ -242,6 +240,7 @@ static void stream_complete(struct Stream *s) unsigned int comp_delay; /* Start the delayed timer. */ + ptimer_transaction_begin(s->ptimer); comp_delay = s->regs[R_DMACR] >> 24; if (comp_delay) { ptimer_stop(s->ptimer); @@ -255,6 +254,7 @@ static void stream_complete(struct Stream *s) s->regs[R_DMASR] |= DMASR_IOC_IRQ; stream_reload_complete_cnt(s); } + ptimer_transaction_commit(s->ptimer); } static void stream_process_mem2s(struct Stream *s, StreamSlave *tx_data_dev, @@ -551,9 +551,10 @@ static void xilinx_axidma_realize(DeviceState *dev, Error **errp) struct Stream *st = &s->streams[i]; st->nr = i; - st->bh = qemu_bh_new(timer_hit, st); - st->ptimer = ptimer_init_with_bh(st->bh, PTIMER_POLICY_DEFAULT); + st->ptimer = ptimer_init(timer_hit, st, PTIMER_POLICY_DEFAULT); + ptimer_transaction_begin(st->ptimer); ptimer_set_freq(st->ptimer, s->freqhz); + ptimer_transaction_commit(st->ptimer); } return; From patchwork Thu Oct 24 16:27:03 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 11210489 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 13C85139A for ; Thu, 24 Oct 2019 17:21:26 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id DCCB320659 for ; Thu, 24 Oct 2019 17:21:25 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="Z40pSTqO" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DCCB320659 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:48576 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNgnc-0002AS-8R for patchwork-qemu-devel@patchwork.kernel.org; Thu, 24 Oct 2019 13:21:24 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58093) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNfy2-0007px-Je for qemu-devel@nongnu.org; Thu, 24 Oct 2019 12:28:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iNfy1-0000vC-Ht for qemu-devel@nongnu.org; Thu, 24 Oct 2019 12:28:06 -0400 Received: from mail-wr1-x434.google.com ([2a00:1450:4864:20::434]:36438) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iNfy1-0000ug-Bs for qemu-devel@nongnu.org; Thu, 24 Oct 2019 12:28:05 -0400 Received: by mail-wr1-x434.google.com with SMTP id w18so26261015wrt.3 for ; Thu, 24 Oct 2019 09:28:05 -0700 (PDT) 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=OpXzWlpJhscet03TTtHAiTy/AAuzQKIKHX9oxfpPCRA=; b=Z40pSTqONB80Oqdhm67lCCdlNQ71V4OZzAWYdURlvvQdRJ3d4cQRGYAAbJnUQZNyv/ m0qOqHaXil+e6Ovw7s/rkERoEvJ4E3vOx+7zkKA7y7NbyOXTY2f1HTNOvaCNJ1LjD3TQ UFPmwXk74jfu5KndmJjPqAfzeE4+H14GY+1+nGGJhily+/tOJWYJNjEMyq6CRsGzwOGZ 90Gc75W0Q5Jp4lFXv9GTMyz4TJ7avq6xXqIh8BTmALg8VEBEjfgedhr5RsPzz9djwMAj n+tC6i5kolSakty4vi3dtImeI1x3GUr7iqNN+vOC/bJpjx+tJmsfiTPmDxva8v95T6hK ziMg== 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=OpXzWlpJhscet03TTtHAiTy/AAuzQKIKHX9oxfpPCRA=; b=cep53tLO/w6n0dGk0xvjv+mh92O3jtmnI67OwH+L/O/yz9Sd8uKPItYbrJhY4t27WU XCTXeZ3+Dz7c5NYophgOxqGI9brc550GGstoDVYhNQhPV0AciL+BvwldEgsmL/J1qu18 FCNF6Gi/8IExpHtANeXSKSdqy3P7kkU8QlrmiNdaog3cCwLYu8ZJmIUoFnSWYdaYkrLK roNWmmBBQBi/AiHWdPK94wQIzMncTBo1z55hO3B6SfvQL2tTHi1Dhhg2dPx77nM3SE+b ablo0Ytf1oYuXl0U6fKa+AAo3vw+sxN567RE1M99xjcZqDo0oCVyjUaSMXxt4jLPMvE9 etZA== X-Gm-Message-State: APjAAAV/dD3xSAzFQdQV0ZF5dXwW+AHLQzkkRx1LfvudxtASEqa0eNHp fnPe00eUkpdVX5MMzue4jXE4HGIQJHg= X-Google-Smtp-Source: APXvYqxVMBfIW8io26v6Le+ppyea6QBlGE77MmLFS0XBReN9BlvMVDKo7w7qyr0P50kjpMMozb77Ew== X-Received: by 2002:a05:6000:34f:: with SMTP id e15mr5074847wre.232.1571934484111; Thu, 24 Oct 2019 09:28:04 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id r27sm42606124wrc.55.2019.10.24.09.28.02 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Oct 2019 09:28:02 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 30/51] hw/timer/slavio_timer: Remove useless check for NULL t->timer Date: Thu, 24 Oct 2019 17:27:03 +0100 Message-Id: <20191024162724.31675-31-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191024162724.31675-1-peter.maydell@linaro.org> References: <20191024162724.31675-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 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" In the slavio timer devcie, the ptimer TimerContext::timer is always created by slavio_timer_init(), so there's no need to check it for NULL; remove the single unneeded NULL check. This will be useful to avoid compiler/Coverity errors when a subsequent change adds a use of t->timer before the location we currently do the NULL check. Signed-off-by: Peter Maydell Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson Message-id: 20191021134357.14266-2-peter.maydell@linaro.org Signed-off-by: Peter Maydell --- hw/timer/slavio_timer.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/hw/timer/slavio_timer.c b/hw/timer/slavio_timer.c index 692d213897d..890dd53f8d8 100644 --- a/hw/timer/slavio_timer.c +++ b/hw/timer/slavio_timer.c @@ -227,13 +227,11 @@ static void slavio_timer_mem_writel(void *opaque, hwaddr addr, // set limit, reset counter qemu_irq_lower(t->irq); t->limit = val & TIMER_MAX_COUNT32; - if (t->timer) { - if (t->limit == 0) { /* free-run */ - ptimer_set_limit(t->timer, - LIMIT_TO_PERIODS(TIMER_MAX_COUNT32), 1); - } else { - ptimer_set_limit(t->timer, LIMIT_TO_PERIODS(t->limit), 1); - } + if (t->limit == 0) { /* free-run */ + ptimer_set_limit(t->timer, + LIMIT_TO_PERIODS(TIMER_MAX_COUNT32), 1); + } else { + ptimer_set_limit(t->timer, LIMIT_TO_PERIODS(t->limit), 1); } } break; From patchwork Thu Oct 24 16:27:04 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 11210401 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 165F3139A for ; Thu, 24 Oct 2019 17:08:38 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id DFE5420650 for ; Thu, 24 Oct 2019 17:08:37 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="y22cxE4w" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DFE5420650 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:48334 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNgbE-0005n5-JZ for patchwork-qemu-devel@patchwork.kernel.org; Thu, 24 Oct 2019 13:08:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58115) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNfy4-0007tW-Hs for qemu-devel@nongnu.org; Thu, 24 Oct 2019 12:28:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iNfy3-0000w7-3Y for qemu-devel@nongnu.org; Thu, 24 Oct 2019 12:28:08 -0400 Received: from mail-wr1-x443.google.com ([2a00:1450:4864:20::443]:39015) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iNfy2-0000vj-T6 for qemu-devel@nongnu.org; Thu, 24 Oct 2019 12:28:07 -0400 Received: by mail-wr1-x443.google.com with SMTP id a11so10714854wra.6 for ; Thu, 24 Oct 2019 09:28:06 -0700 (PDT) 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=SSIRbdIen/7fg/3VtseNziJYU9KzRrDZCTawNXozh3I=; b=y22cxE4wfhbYgnmyjP4CDSeN5PCVMUOWL4J/ROx7CvUOChnsGZJx3TujBkED6JIutJ 8lhbmzlXyTeN0kypgs86J1g7tv9YXjMVmlIw+PMWalk9WBh/8Ud7GC79UL5TGN8FWJGS iSO9LM7SZpu1w9F8kJ5XnrUMalzAyyYZMs0lVeOOgI2kiIKrF9p9ierQAyrAv4C5GUF/ siBTDiYUqSgkPtfaci7NLfMXf5wyZ1Ahj71BLj4HtFX9AOctGMxFui8vt8FWjrg73HCT 8DFDLizVrACJIzKkJgyKmki9KBMO5WvAZuZVVYgn5GS0kEnxRfCOTHWc0JlydbvcffTA Gbyw== 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=SSIRbdIen/7fg/3VtseNziJYU9KzRrDZCTawNXozh3I=; b=STRH+hulWhDg8eZh4H2iKShKPPWhWi5SbbIGMd1IbAbsnwKDUBH69wwQlwi59rTO4q NDRuiSe2XGNqem4A1/ax7xf9GZF4qjDYzNj7dsF7hlcBiG7JRai7D4WMjNbrGdOMmCCZ T3ffPoqUJUa274spC04lWc36qCZ99H3Oml5e9tZkW0WsHZEyVA4ZbczcYluiNOlo7Fom Ca7Cfyrkr8spxJUjP0vgT77M2HZQiFpON+gECRCIm0XA5pK6R0zjgqah0XAfnRKm7TR/ 7wr7+WESJDcKAqsdfhdMGSBVMdLrUWb0Mp1NoLC7yv97y3RD2zQUhbBGUica1tTz5z3h xd/g== X-Gm-Message-State: APjAAAUl1dBn53lDf7aXfbEQNQ0wSe8IwqUERQx46aBkz6KGsJfFWbaq IkKllwbjKQjQ1+WFY409B9KQBqBa92c= X-Google-Smtp-Source: APXvYqz5c8vrtm8DS2d5ce0hrgQdMm8bBsEvYrMUclsl6mbkNFFCSMtWlH9mMSOfIPdl5xrXWMnomA== X-Received: by 2002:a5d:464f:: with SMTP id j15mr4658975wrs.366.1571934485507; Thu, 24 Oct 2019 09:28:05 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id r27sm42606124wrc.55.2019.10.24.09.28.04 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Oct 2019 09:28:04 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 31/51] hw/timer/slavio_timer.c: Switch to transaction-based ptimer API Date: Thu, 24 Oct 2019 17:27:04 +0100 Message-Id: <20191024162724.31675-32-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191024162724.31675-1-peter.maydell@linaro.org> References: <20191024162724.31675-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 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" Switch the slavio_timer code away from bottom-half based ptimers to the new transaction-based ptimer API. This just requires adding begin/commit calls around the various places that modify the ptimer state, and using the new ptimer_init() function to create the timer. Signed-off-by: Peter Maydell Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson Message-id: 20191021134357.14266-4-peter.maydell@linaro.org Signed-off-by: Peter Maydell --- hw/timer/slavio_timer.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/hw/timer/slavio_timer.c b/hw/timer/slavio_timer.c index 890dd53f8d8..c55e8d0bf42 100644 --- a/hw/timer/slavio_timer.c +++ b/hw/timer/slavio_timer.c @@ -30,7 +30,6 @@ #include "hw/sysbus.h" #include "migration/vmstate.h" #include "trace.h" -#include "qemu/main-loop.h" #include "qemu/module.h" /* @@ -213,6 +212,7 @@ static void slavio_timer_mem_writel(void *opaque, hwaddr addr, saddr = addr >> 2; switch (saddr) { case TIMER_LIMIT: + ptimer_transaction_begin(t->timer); if (slavio_timer_is_user(tc)) { uint64_t count; @@ -234,6 +234,7 @@ static void slavio_timer_mem_writel(void *opaque, hwaddr addr, ptimer_set_limit(t->timer, LIMIT_TO_PERIODS(t->limit), 1); } } + ptimer_transaction_commit(t->timer); break; case TIMER_COUNTER: if (slavio_timer_is_user(tc)) { @@ -245,7 +246,9 @@ static void slavio_timer_mem_writel(void *opaque, hwaddr addr, t->reached = 0; count = ((uint64_t)t->counthigh) << 32 | t->count; trace_slavio_timer_mem_writel_limit(timer_index, count); + ptimer_transaction_begin(t->timer); ptimer_set_count(t->timer, LIMIT_TO_PERIODS(t->limit - count)); + ptimer_transaction_commit(t->timer); } else { trace_slavio_timer_mem_writel_counter_invalid(); } @@ -253,13 +256,16 @@ static void slavio_timer_mem_writel(void *opaque, hwaddr addr, case TIMER_COUNTER_NORST: // set limit without resetting counter t->limit = val & TIMER_MAX_COUNT32; + ptimer_transaction_begin(t->timer); if (t->limit == 0) { /* free-run */ ptimer_set_limit(t->timer, LIMIT_TO_PERIODS(TIMER_MAX_COUNT32), 0); } else { ptimer_set_limit(t->timer, LIMIT_TO_PERIODS(t->limit), 0); } + ptimer_transaction_commit(t->timer); break; case TIMER_STATUS: + ptimer_transaction_begin(t->timer); if (slavio_timer_is_user(tc)) { // start/stop user counter if (val & 1) { @@ -271,6 +277,7 @@ static void slavio_timer_mem_writel(void *opaque, hwaddr addr, } } t->run = val & 1; + ptimer_transaction_commit(t->timer); break; case TIMER_MODE: if (timer_index == 0) { @@ -280,6 +287,7 @@ static void slavio_timer_mem_writel(void *opaque, hwaddr addr, unsigned int processor = 1 << i; CPUTimerState *curr_timer = &s->cputimer[i + 1]; + ptimer_transaction_begin(curr_timer->timer); // check for a change in timer mode for this processor if ((val & processor) != (s->cputimer_mode & processor)) { if (val & processor) { // counter -> user timer @@ -306,6 +314,7 @@ static void slavio_timer_mem_writel(void *opaque, hwaddr addr, trace_slavio_timer_mem_writel_mode_counter(timer_index); } } + ptimer_transaction_commit(curr_timer->timer); } } else { trace_slavio_timer_mem_writel_mode_invalid(); @@ -365,10 +374,12 @@ static void slavio_timer_reset(DeviceState *d) curr_timer->count = 0; curr_timer->reached = 0; if (i <= s->num_cpus) { + ptimer_transaction_begin(curr_timer->timer); ptimer_set_limit(curr_timer->timer, LIMIT_TO_PERIODS(TIMER_MAX_COUNT32), 1); ptimer_run(curr_timer->timer, 0); curr_timer->run = 1; + ptimer_transaction_commit(curr_timer->timer); } } s->cputimer_mode = 0; @@ -378,7 +389,6 @@ static void slavio_timer_init(Object *obj) { SLAVIO_TIMERState *s = SLAVIO_TIMER(obj); SysBusDevice *dev = SYS_BUS_DEVICE(obj); - QEMUBH *bh; unsigned int i; TimerContext *tc; @@ -390,9 +400,11 @@ static void slavio_timer_init(Object *obj) tc->s = s; tc->timer_index = i; - bh = qemu_bh_new(slavio_timer_irq, tc); - s->cputimer[i].timer = ptimer_init_with_bh(bh, PTIMER_POLICY_DEFAULT); + s->cputimer[i].timer = ptimer_init(slavio_timer_irq, tc, + PTIMER_POLICY_DEFAULT); + ptimer_transaction_begin(s->cputimer[i].timer); ptimer_set_period(s->cputimer[i].timer, TIMER_PERIOD); + ptimer_transaction_commit(s->cputimer[i].timer); size = i == 0 ? SYS_TIMER_SIZE : CPU_TIMER_SIZE; snprintf(timer_name, sizeof(timer_name), "timer-%i", i); From patchwork Thu Oct 24 16:27:05 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 11210403 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4A094112C for ; Thu, 24 Oct 2019 17:09:13 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 204B120650 for ; Thu, 24 Oct 2019 17:09:13 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="q5wOMzfB" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 204B120650 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:48356 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNgbn-0007My-MS for patchwork-qemu-devel@patchwork.kernel.org; Thu, 24 Oct 2019 13:09:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58127) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNfy6-0007vr-AG for qemu-devel@nongnu.org; Thu, 24 Oct 2019 12:28:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iNfy4-0000wp-3k for qemu-devel@nongnu.org; Thu, 24 Oct 2019 12:28:09 -0400 Received: from mail-wr1-x441.google.com ([2a00:1450:4864:20::441]:34393) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iNfy3-0000wd-TR for qemu-devel@nongnu.org; Thu, 24 Oct 2019 12:28:08 -0400 Received: by mail-wr1-x441.google.com with SMTP id t16so21672295wrr.1 for ; Thu, 24 Oct 2019 09:28:07 -0700 (PDT) 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=mBAa8aOzaEjXceVb3slP1wzsJg0PhsoOqpMdKz0RtWI=; b=q5wOMzfBUZSBfoYqvwoI3DZ0t3VubE6hhsTEl1Ga43k3ckJPOPHe9xq5BJMzrUHK4g NFisXtDSB+CeqgpvpW9YRUFmfxUCkwxo2GSIdNzcSfnbz+1fKkdX9RQcj8ZZbk+seU0h l3X3pcVLxHBtkKGZN3jBl8m5ndJGo6UYc9PcyKxTM7rsTsI0yIIR9LMgcQ2s22SS7Hnl 9HwrapTt5wHLumq+K7wlMC0oDM93BNVKqTo6QLDxEE9P5/O8N0XyKZYPGFiMYwoKbwW8 FqdoXc2kdZ4YcPJt0Nf2WvdYt8v56hhNR4yjBA3ZeA1egn11V+NQ7bD1wCcq+UAUDGaB E1pQ== 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=mBAa8aOzaEjXceVb3slP1wzsJg0PhsoOqpMdKz0RtWI=; b=SAMjlRpiasqKMIr/L2JOYlpSB7zDlb14nBHxt3N0HqCM+rdFrCwaDu6ce9DzGh5Ghz h1wOZyBo3Sbi76o3LUP4sgf9VBe7ORphuqS5CelhhMAxba+2jOYV3ncSmJ24xq0MtRjV w0QrqvDdywjjZ7sGI1L7uu9VJVoZ0iheN2vgZMQR/rsqCCQUrzvkopHBS9eZAw4kjjil x4l3T0vdWdWnI1xxWcVCFuHoUyLR+yTrImcN1a3VtPtLfO1UI0dg9ZC4N4fOlXwkUpzP aOdow7j2+n53mL1P7mmqVf6zkGUHBjwdMCzybvPkjJVvgCOmdkZzyWDpCiZWgL/Z6Hew xMog== X-Gm-Message-State: APjAAAXFu26kz1v6OJD/LJGoW9FSBnNbV73hu1PpnXIw1gtFzSHOG+l3 NbmX9O6diUmCVuj2rU6qbDLL9KGX3gM= X-Google-Smtp-Source: APXvYqz4p9YF4uDfPnmJbqM+lki7tb+ShC9krv5KZSkmZeBhzS8T8ciXrqEKjVARprZ+XTP7Ue9IeA== X-Received: by 2002:adf:ce87:: with SMTP id r7mr4584277wrn.307.1571934486640; Thu, 24 Oct 2019 09:28:06 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id r27sm42606124wrc.55.2019.10.24.09.28.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Oct 2019 09:28:05 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 32/51] hw/timer/grlib_gptimer.c: Switch to transaction-based ptimer API Date: Thu, 24 Oct 2019 17:27:05 +0100 Message-Id: <20191024162724.31675-33-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191024162724.31675-1-peter.maydell@linaro.org> References: <20191024162724.31675-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::441 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" Switch the grlib_gptimer code away from bottom-half based ptimers to the new transaction-based ptimer API. This just requires adding begin/commit calls around the various places that modify the ptimer state, and using the new ptimer_init() function to create the timer. Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé Message-id: 20191021134357.14266-3-peter.maydell@linaro.org Signed-off-by: Peter Maydell --- hw/timer/grlib_gptimer.c | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/hw/timer/grlib_gptimer.c b/hw/timer/grlib_gptimer.c index bb09268ea14..7a9371c0e30 100644 --- a/hw/timer/grlib_gptimer.c +++ b/hw/timer/grlib_gptimer.c @@ -29,7 +29,6 @@ #include "hw/irq.h" #include "hw/ptimer.h" #include "hw/qdev-properties.h" -#include "qemu/main-loop.h" #include "qemu/module.h" #include "trace.h" @@ -63,7 +62,6 @@ typedef struct GPTimer GPTimer; typedef struct GPTimerUnit GPTimerUnit; struct GPTimer { - QEMUBH *bh; struct ptimer_state *ptimer; qemu_irq irq; @@ -93,6 +91,17 @@ struct GPTimerUnit { uint32_t config; }; +static void grlib_gptimer_tx_begin(GPTimer *timer) +{ + ptimer_transaction_begin(timer->ptimer); +} + +static void grlib_gptimer_tx_commit(GPTimer *timer) +{ + ptimer_transaction_commit(timer->ptimer); +} + +/* Must be called within grlib_gptimer_tx_begin/commit block */ static void grlib_gptimer_enable(GPTimer *timer) { assert(timer != NULL); @@ -115,6 +124,7 @@ static void grlib_gptimer_enable(GPTimer *timer) ptimer_run(timer->ptimer, 1); } +/* Must be called within grlib_gptimer_tx_begin/commit block */ static void grlib_gptimer_restart(GPTimer *timer) { assert(timer != NULL); @@ -141,7 +151,9 @@ static void grlib_gptimer_set_scaler(GPTimerUnit *unit, uint32_t scaler) trace_grlib_gptimer_set_scaler(scaler, value); for (i = 0; i < unit->nr_timers; i++) { + ptimer_transaction_begin(unit->timers[i].ptimer); ptimer_set_freq(unit->timers[i].ptimer, value); + ptimer_transaction_commit(unit->timers[i].ptimer); } } @@ -266,8 +278,10 @@ static void grlib_gptimer_write(void *opaque, hwaddr addr, switch (timer_addr) { case COUNTER_OFFSET: trace_grlib_gptimer_writel(id, addr, value); + grlib_gptimer_tx_begin(&unit->timers[id]); unit->timers[id].counter = value; grlib_gptimer_enable(&unit->timers[id]); + grlib_gptimer_tx_commit(&unit->timers[id]); return; case COUNTER_RELOAD_OFFSET: @@ -291,6 +305,7 @@ static void grlib_gptimer_write(void *opaque, hwaddr addr, /* gptimer_restart calls gptimer_enable, so if "enable" and "load" bits are present, we just have to call restart. */ + grlib_gptimer_tx_begin(&unit->timers[id]); if (value & GPTIMER_LOAD) { grlib_gptimer_restart(&unit->timers[id]); } else if (value & GPTIMER_ENABLE) { @@ -301,6 +316,7 @@ static void grlib_gptimer_write(void *opaque, hwaddr addr, value &= ~(GPTIMER_LOAD & GPTIMER_DEBUG_HALT); unit->timers[id].config = value; + grlib_gptimer_tx_commit(&unit->timers[id]); return; default: @@ -344,9 +360,11 @@ static void grlib_gptimer_reset(DeviceState *d) timer->counter = 0; timer->reload = 0; timer->config = 0; + ptimer_transaction_begin(timer->ptimer); ptimer_stop(timer->ptimer); ptimer_set_count(timer->ptimer, 0); ptimer_set_freq(timer->ptimer, unit->freq_hz); + ptimer_transaction_commit(timer->ptimer); } } @@ -365,14 +383,16 @@ static void grlib_gptimer_realize(DeviceState *dev, Error **errp) GPTimer *timer = &unit->timers[i]; timer->unit = unit; - timer->bh = qemu_bh_new(grlib_gptimer_hit, timer); - timer->ptimer = ptimer_init_with_bh(timer->bh, PTIMER_POLICY_DEFAULT); + timer->ptimer = ptimer_init(grlib_gptimer_hit, timer, + PTIMER_POLICY_DEFAULT); timer->id = i; /* One IRQ line for each timer */ sysbus_init_irq(sbd, &timer->irq); + ptimer_transaction_begin(timer->ptimer); ptimer_set_freq(timer->ptimer, unit->freq_hz); + ptimer_transaction_commit(timer->ptimer); } memory_region_init_io(&unit->iomem, OBJECT(unit), &grlib_gptimer_ops, From patchwork Thu Oct 24 16:27:06 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 11210409 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 23E45139A for ; Thu, 24 Oct 2019 17:11:37 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id ED97D20650 for ; Thu, 24 Oct 2019 17:11:36 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="c1UvOL+Z" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org ED97D20650 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:48390 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNge7-00041e-JA for patchwork-qemu-devel@patchwork.kernel.org; Thu, 24 Oct 2019 13:11:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58148) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNfy7-0007z8-KI for qemu-devel@nongnu.org; Thu, 24 Oct 2019 12:28:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iNfy6-0000xi-FA for qemu-devel@nongnu.org; Thu, 24 Oct 2019 12:28:11 -0400 Received: from mail-wr1-x442.google.com ([2a00:1450:4864:20::442]:39015) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iNfy6-0000xE-9N for qemu-devel@nongnu.org; Thu, 24 Oct 2019 12:28:10 -0400 Received: by mail-wr1-x442.google.com with SMTP id a11so10714966wra.6 for ; Thu, 24 Oct 2019 09:28:09 -0700 (PDT) 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=J21kyHeYFa+RY7GcWXJAZvmmTTUgznnvXHxn75vs05A=; b=c1UvOL+ZcoyfHigvuNr9oOa5gz0YKfEj0cmPw1DuUWoh8Vs8g4zcGqK/GoizhB01UP 8xAwfC+vkMGHnUyb/m1jmCr291Rf+v8Ope1LltBpzSPj4WIJPVDRq/QNaZreT5XIm/+Q AVuYYP3aA0tMqDIqo25vzdFAhWGJj/1NHXBxPd6LgoPGIn5fTIb8PIomw6egGo/L7EE0 oxDnVPLalMSAbL1R4VQpCcf2FJX+rSFgT4PzbH/aAdmN6L8s/5PvdcUfdOSntg4p7B3i RoM7zlKrpqtkvEs1/I9gGZIrqNGecTdjCfjQVxtTWKLXrDK/SpZhtdWgAxg+EB1gbcK/ dowg== 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=J21kyHeYFa+RY7GcWXJAZvmmTTUgznnvXHxn75vs05A=; b=nTVFQvhvE/xcTeGfFk4MWdicMrLU2lylXFGzEi2cN4o4xNn3VodQyl7ZTAwzx9sTkU ThBEYhvGDjWeUkw0ZaNeRRfNZurAf7SZ6Xtb3KMVbw1VzE0l7KeiXgVpqkBytdjfQu/d uUtsx+B8ka1b6TTOBfICT+oUijY5OJ3ZCdalAKbZr6VfGFRJ+4wuB2QMDppj3dhysz4R iQ/tg0ySH0vHdBWzIFK9C+TLRL6JtcEfgVuQBMolmgYVbVKaCzzj/vDA6zPajTb1+4Xi 1dfYp+IuCN4QaKccMTL/ez3hmA/hLKABqulCXxdAAiINi+0G1JjKwT8JijyL/j8r5v9Y wsrw== X-Gm-Message-State: APjAAAUHaFmKAUy5EcBwBt3CyUzA7fzVF96zmjzjSByZjRSYVekd/PT9 bJHXhBhPFCv2IJwx31/Grri8+zNVl8E= X-Google-Smtp-Source: APXvYqyU26pU3Oi9FioIDWaPoR2V09qVT2df71ZItWcrVijFyRQkeq7EbhYgIQ6QIeW9TMouPIOzpQ== X-Received: by 2002:adf:f04e:: with SMTP id t14mr4448645wro.106.1571934488067; Thu, 24 Oct 2019 09:28:08 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id r27sm42606124wrc.55.2019.10.24.09.28.06 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Oct 2019 09:28:07 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 33/51] hw/m68k/mcf5206.c: Switch to transaction-based ptimer API Date: Thu, 24 Oct 2019 17:27:06 +0100 Message-Id: <20191024162724.31675-34-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191024162724.31675-1-peter.maydell@linaro.org> References: <20191024162724.31675-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 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" Switch the mcf5206 code away from bottom-half based ptimers to the new transaction-based ptimer API. This just requires adding begin/commit calls around the various places that modify the ptimer state, and using the new ptimer_init() function to create the timer. Signed-off-by: Peter Maydell Reviewed-by: Thomas Huth Message-id: 20191021140600.10725-1-peter.maydell@linaro.org --- hw/m68k/mcf5206.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/hw/m68k/mcf5206.c b/hw/m68k/mcf5206.c index a49096367cb..b155dd81705 100644 --- a/hw/m68k/mcf5206.c +++ b/hw/m68k/mcf5206.c @@ -8,7 +8,6 @@ #include "qemu/osdep.h" #include "qemu/error-report.h" -#include "qemu/main-loop.h" #include "cpu.h" #include "hw/hw.h" #include "hw/irq.h" @@ -57,10 +56,12 @@ static void m5206_timer_recalibrate(m5206_timer_state *s) int prescale; int mode; + ptimer_transaction_begin(s->timer); ptimer_stop(s->timer); - if ((s->tmr & TMR_RST) == 0) - return; + if ((s->tmr & TMR_RST) == 0) { + goto exit; + } prescale = (s->tmr >> 8) + 1; mode = (s->tmr >> 1) & 3; @@ -78,6 +79,8 @@ static void m5206_timer_recalibrate(m5206_timer_state *s) ptimer_set_limit(s->timer, s->trr, 0); ptimer_run(s->timer, 0); +exit: + ptimer_transaction_commit(s->timer); } static void m5206_timer_trigger(void *opaque) @@ -123,7 +126,9 @@ static void m5206_timer_write(m5206_timer_state *s, uint32_t addr, uint32_t val) s->tcr = val; break; case 0xc: + ptimer_transaction_begin(s->timer); ptimer_set_count(s->timer, val); + ptimer_transaction_commit(s->timer); break; case 0x11: s->ter &= ~val; @@ -137,11 +142,9 @@ static void m5206_timer_write(m5206_timer_state *s, uint32_t addr, uint32_t val) static m5206_timer_state *m5206_timer_init(qemu_irq irq) { m5206_timer_state *s; - QEMUBH *bh; s = g_new0(m5206_timer_state, 1); - bh = qemu_bh_new(m5206_timer_trigger, s); - s->timer = ptimer_init_with_bh(bh, PTIMER_POLICY_DEFAULT); + s->timer = ptimer_init(m5206_timer_trigger, s, PTIMER_POLICY_DEFAULT); s->irq = irq; m5206_timer_reset(s); return s; From patchwork Thu Oct 24 16:27:07 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 11210407 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4D580112C for ; Thu, 24 Oct 2019 17:10:25 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 231DF20650 for ; Thu, 24 Oct 2019 17:10:25 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="bh0tUVgC" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 231DF20650 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:48374 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNgcx-0001e8-Pl for patchwork-qemu-devel@patchwork.kernel.org; Thu, 24 Oct 2019 13:10:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58150) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNfy7-0007zY-Q0 for qemu-devel@nongnu.org; Thu, 24 Oct 2019 12:28:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iNfy6-0000xp-He for qemu-devel@nongnu.org; Thu, 24 Oct 2019 12:28:11 -0400 Received: from mail-wr1-x442.google.com ([2a00:1450:4864:20::442]:44573) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iNfy6-0000xQ-BM for qemu-devel@nongnu.org; Thu, 24 Oct 2019 12:28:10 -0400 Received: by mail-wr1-x442.google.com with SMTP id z11so3425828wro.11 for ; Thu, 24 Oct 2019 09:28:10 -0700 (PDT) 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=8gomn01XLvBOBw7vPQuO9R/LxnmjSiX180WMSIb6GFs=; b=bh0tUVgC/1ZbJ36SIsl+8vE6Dh0rK+GQ7ttrbMOIz7zDP5jvg4yq9wto8Bi/0N+fNb RbZCRzahCVbNs6fCGqXsaL33FyS80pIzSg1ugDWhRHk7wzGhOiplVgm8JZo3hPaOqPT3 5AlB/ZD9zHH3f78/jdzVGTexLwjICSXqNVpBNCRdTJRGp2kK3GWCKNLXKINzjd/5uF+i 3Puh6JkPji3sSli1UsgUjPK8cbkW8f77K96uOSkaCEKdjoyf9ZLD4qHPsxJiIHcZzeZ5 BtlXraBReXp+3V+uJ7ne9+8WYUqtxse2JsrsTfL0wfKpFY8KQttxDu+YmNaACBJXkwmE zvQA== 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=8gomn01XLvBOBw7vPQuO9R/LxnmjSiX180WMSIb6GFs=; b=UbI0eIbwFZKsRIZgbXLU1whf7wPZT5b4wCmOaxKUE/sIh/qLUe0FJhXWpikZTCMWd/ 4DciBq873y8i6m+zJSRR+ihZ0hGYgdoI6I9QUkYKIwN5ARZrYZsy9tDq1dGLVmnqskDC fS/+8vF2CgicO00k6mlcTSLis5sNu3SpKqhPuqL9uIdiHm+PduXDb5bLX1GMpl0vJY0X sJd9u5KMzxPfXwfSlyijyM225d7uqcrnBUDNl6RhvuPPPxlTN7MvjLECH83W7eRstS0n THZpMOML6W+alKJEagA0d7qbAcvVOFWI/N9zHgmJy8ZEmC7Sy49kNLyGDwjfjiyLG5D3 SiKw== X-Gm-Message-State: APjAAAWIh1XJO4gtrZ+qKVk5QCPVM4cPpwz/kZVxZyIRT4v+XJdy5NAo JbNUOPb2GZWu1q4I9YFtfz3J6RFMW3M= X-Google-Smtp-Source: APXvYqzkM5AqjDl5AK8uaa7Y8UMD0pA7fmI+yofFFxSDNM+FnQ4rnqqTOhBh+07y3ZS2V+HnYy62pw== X-Received: by 2002:a05:6000:4f:: with SMTP id k15mr4416110wrx.137.1571934489134; Thu, 24 Oct 2019 09:28:09 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id r27sm42606124wrc.55.2019.10.24.09.28.08 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Oct 2019 09:28:08 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 34/51] hw/watchdog/milkymist-sysctl.c: Switch to transaction-based ptimer API Date: Thu, 24 Oct 2019 17:27:07 +0100 Message-Id: <20191024162724.31675-35-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191024162724.31675-1-peter.maydell@linaro.org> References: <20191024162724.31675-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 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" Switch the milkymist-sysctl code away from bottom-half based ptimers to the new transaction-based ptimer API. This just requires adding begin/commit calls around the various places that modify the ptimer state, and using the new ptimer_init() function to create the timer. Signed-off-by: Peter Maydell Reviewed-by: Philippe Mathieu-Daudé Message-id: 20191021141040.11007-1-peter.maydell@linaro.org --- hw/timer/milkymist-sysctl.c | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/hw/timer/milkymist-sysctl.c b/hw/timer/milkymist-sysctl.c index 5193c038501..7a62e212c35 100644 --- a/hw/timer/milkymist-sysctl.c +++ b/hw/timer/milkymist-sysctl.c @@ -31,7 +31,6 @@ #include "hw/ptimer.h" #include "hw/qdev-properties.h" #include "qemu/error-report.h" -#include "qemu/main-loop.h" #include "qemu/module.h" enum { @@ -71,8 +70,6 @@ struct MilkymistSysctlState { MemoryRegion regs_region; - QEMUBH *bh0; - QEMUBH *bh1; ptimer_state *ptimer0; ptimer_state *ptimer1; @@ -161,14 +158,19 @@ static void sysctl_write(void *opaque, hwaddr addr, uint64_t value, s->regs[addr] = value; break; case R_TIMER0_COMPARE: + ptimer_transaction_begin(s->ptimer0); ptimer_set_limit(s->ptimer0, value, 0); s->regs[addr] = value; + ptimer_transaction_commit(s->ptimer0); break; case R_TIMER1_COMPARE: + ptimer_transaction_begin(s->ptimer1); ptimer_set_limit(s->ptimer1, value, 0); s->regs[addr] = value; + ptimer_transaction_commit(s->ptimer1); break; case R_TIMER0_CONTROL: + ptimer_transaction_begin(s->ptimer0); s->regs[addr] = value; if (s->regs[R_TIMER0_CONTROL] & CTRL_ENABLE) { trace_milkymist_sysctl_start_timer0(); @@ -179,8 +181,10 @@ static void sysctl_write(void *opaque, hwaddr addr, uint64_t value, trace_milkymist_sysctl_stop_timer0(); ptimer_stop(s->ptimer0); } + ptimer_transaction_commit(s->ptimer0); break; case R_TIMER1_CONTROL: + ptimer_transaction_begin(s->ptimer1); s->regs[addr] = value; if (s->regs[R_TIMER1_CONTROL] & CTRL_ENABLE) { trace_milkymist_sysctl_start_timer1(); @@ -191,6 +195,7 @@ static void sysctl_write(void *opaque, hwaddr addr, uint64_t value, trace_milkymist_sysctl_stop_timer1(); ptimer_stop(s->ptimer1); } + ptimer_transaction_commit(s->ptimer1); break; case R_ICAP: sysctl_icap_write(s, value); @@ -263,8 +268,12 @@ static void milkymist_sysctl_reset(DeviceState *d) s->regs[i] = 0; } + ptimer_transaction_begin(s->ptimer0); ptimer_stop(s->ptimer0); + ptimer_transaction_commit(s->ptimer0); + ptimer_transaction_begin(s->ptimer1); ptimer_stop(s->ptimer1); + ptimer_transaction_commit(s->ptimer1); /* defaults */ s->regs[R_ICAP] = ICAP_READY; @@ -292,13 +301,15 @@ static void milkymist_sysctl_realize(DeviceState *dev, Error **errp) { MilkymistSysctlState *s = MILKYMIST_SYSCTL(dev); - s->bh0 = qemu_bh_new(timer0_hit, s); - s->bh1 = qemu_bh_new(timer1_hit, s); - s->ptimer0 = ptimer_init_with_bh(s->bh0, PTIMER_POLICY_DEFAULT); - s->ptimer1 = ptimer_init_with_bh(s->bh1, PTIMER_POLICY_DEFAULT); + s->ptimer0 = ptimer_init(timer0_hit, s, PTIMER_POLICY_DEFAULT); + s->ptimer1 = ptimer_init(timer1_hit, s, PTIMER_POLICY_DEFAULT); + ptimer_transaction_begin(s->ptimer0); ptimer_set_freq(s->ptimer0, s->freq_hz); + ptimer_transaction_commit(s->ptimer0); + ptimer_transaction_begin(s->ptimer1); ptimer_set_freq(s->ptimer1, s->freq_hz); + ptimer_transaction_commit(s->ptimer1); } static const VMStateDescription vmstate_milkymist_sysctl = { From patchwork Thu Oct 24 16:27:08 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 11210479 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 897DD14ED for ; Thu, 24 Oct 2019 17:15:38 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 4EFD820659 for ; Thu, 24 Oct 2019 17:15:38 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="AtlSwa1q" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4EFD820659 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:48484 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNghz-0003LV-Nz for patchwork-qemu-devel@patchwork.kernel.org; Thu, 24 Oct 2019 13:15:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58170) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNfyA-00083o-HY for qemu-devel@nongnu.org; Thu, 24 Oct 2019 12:28:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iNfy8-0000zG-6V for qemu-devel@nongnu.org; Thu, 24 Oct 2019 12:28:14 -0400 Received: from mail-wr1-x441.google.com ([2a00:1450:4864:20::441]:46811) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iNfy7-0000yH-U4 for qemu-devel@nongnu.org; Thu, 24 Oct 2019 12:28:12 -0400 Received: by mail-wr1-x441.google.com with SMTP id n15so16010305wrw.13 for ; Thu, 24 Oct 2019 09:28:11 -0700 (PDT) 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=BcKgN/Z0ywVj7mxh6SURNZkc+EcubD4TLlWRL+FxQrM=; b=AtlSwa1qaYRQxRcDEgb7lnbdiA/6yOckTpiXSC8zhgfkluAHRcWFH8nBszBBIHsJZ5 T4z+yZ6y36P3jKVvTpQ4iorhCJCLQCHlyQeWTuIgx8yziZSxtRAz1ETUNXXJTET99kI0 pFFvCVdO5PoSzmoqCmeuIQMA6pA7+objSt1IrPUMLSU5hTcONrIOhB8S9rzaprxtfPgZ o0wvXfT5LvD4P0Raj4gDOCzA1rdviBJDGmv6o/wVCoyAz7SSh/AqTLY4a0lT3bY/ePkj pmNnVoL6iyWsKDd4zdPIylGGpq6iKiCMLzQUfUIvEWwkY8/i0HITAy+oG7Pbf6wFafLX XSeA== 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=BcKgN/Z0ywVj7mxh6SURNZkc+EcubD4TLlWRL+FxQrM=; b=L4ly5Gb34yc26rQ+tfMDM5prltMgoi8+dT3rp11GfdQT6N3huiEv/yJgQ1PYAo6vsC wNkY4YU0pNEPxOvfts9sCiNdTIZklC8LbQxuqfVCrK4AWr06qwwQFCKNcMfQWe0LLfBJ 6YkyZD3dhwpH+yEgiWHYkfRNIZxq4Wf8q1vm+ldwvxNH0peoTYqJySeDGVlRXpJt4TGV kvcryoGbBPl3YU66g+b7VUYDsQLEbJKnl7qnXkeJZgGUWcIGOquffzMUx8I1FBKHyNOM qGU8fXEn+jxyYNKq08IoIYjh3aaLA7hDA5d10GODAxWEs7LQTCAX7KzhQsdZkFMXzkHb ULSg== X-Gm-Message-State: APjAAAWUDJeagEH9fIyGi2X3h0c38llmrb0QHIrS+dJl09YUork+zx5L +G4rLUrjqIRL+5k38GuVOLEsdc+B1D4= X-Google-Smtp-Source: APXvYqzOsXOX1YCzlMzbqzQS0DG/BAjCkF5BTX4FNvgmnqbqRa4WsECs5ADoLQvLOTA1k3yXRno0FA== X-Received: by 2002:a5d:624f:: with SMTP id m15mr4252626wrv.59.1571934490343; Thu, 24 Oct 2019 09:28:10 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id r27sm42606124wrc.55.2019.10.24.09.28.09 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Oct 2019 09:28:09 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 35/51] target/arm/monitor: Introduce qmp_query_cpu_model_expansion Date: Thu, 24 Oct 2019 17:27:08 +0100 Message-Id: <20191024162724.31675-36-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191024162724.31675-1-peter.maydell@linaro.org> References: <20191024162724.31675-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::441 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" From: Andrew Jones Add support for the query-cpu-model-expansion QMP command to Arm. We do this selectively, only exposing CPU properties which represent optional CPU features which the user may want to enable/disable. Additionally we restrict the list of queryable cpu models to 'max', 'host', or the current type when KVM is in use. And, finally, we only implement expansion type 'full', as Arm does not yet have a "base" CPU type. More details and example queries are described in a new document (docs/arm-cpu-features.rst). Note, certainly more features may be added to the list of advertised features, e.g. 'vfp' and 'neon'. The only requirement is that we can detect invalid configurations and emit failures at QMP query time. For 'vfp' and 'neon' this will require some refactoring to share a validation function between the QMP query and the CPU realize functions. Signed-off-by: Andrew Jones Reviewed-by: Richard Henderson Reviewed-by: Eric Auger Reviewed-by: Beata Michalska Message-id: 20191024121808.9612-2-drjones@redhat.com Signed-off-by: Peter Maydell --- qapi/machine-target.json | 6 +- target/arm/monitor.c | 146 ++++++++++++++++++++++++++++++++++++++ docs/arm-cpu-features.rst | 137 +++++++++++++++++++++++++++++++++++ 3 files changed, 286 insertions(+), 3 deletions(-) create mode 100644 docs/arm-cpu-features.rst diff --git a/qapi/machine-target.json b/qapi/machine-target.json index 55310a6aa22..04623224720 100644 --- a/qapi/machine-target.json +++ b/qapi/machine-target.json @@ -212,7 +212,7 @@ ## { 'struct': 'CpuModelExpansionInfo', 'data': { 'model': 'CpuModelInfo' }, - 'if': 'defined(TARGET_S390X) || defined(TARGET_I386)' } + 'if': 'defined(TARGET_S390X) || defined(TARGET_I386) || defined(TARGET_ARM)' } ## # @query-cpu-model-expansion: @@ -237,7 +237,7 @@ # query-cpu-model-expansion while using these is not advised. # # Some architectures may not support all expansion types. s390x supports -# "full" and "static". +# "full" and "static". Arm only supports "full". # # Returns: a CpuModelExpansionInfo. Returns an error if expanding CPU models is # not supported, if the model cannot be expanded, if the model contains @@ -251,7 +251,7 @@ 'data': { 'type': 'CpuModelExpansionType', 'model': 'CpuModelInfo' }, 'returns': 'CpuModelExpansionInfo', - 'if': 'defined(TARGET_S390X) || defined(TARGET_I386)' } + 'if': 'defined(TARGET_S390X) || defined(TARGET_I386) || defined(TARGET_ARM)' } ## # @CpuDefinitionInfo: diff --git a/target/arm/monitor.c b/target/arm/monitor.c index 6457c3c87f7..560970de7f5 100644 --- a/target/arm/monitor.c +++ b/target/arm/monitor.c @@ -21,8 +21,16 @@ */ #include "qemu/osdep.h" +#include "hw/boards.h" #include "kvm_arm.h" +#include "qapi/error.h" +#include "qapi/visitor.h" +#include "qapi/qobject-input-visitor.h" +#include "qapi/qapi-commands-machine-target.h" #include "qapi/qapi-commands-misc-target.h" +#include "qapi/qmp/qerror.h" +#include "qapi/qmp/qdict.h" +#include "qom/qom-qobject.h" static GICCapability *gic_cap_new(int version) { @@ -81,3 +89,141 @@ GICCapabilityList *qmp_query_gic_capabilities(Error **errp) return head; } + +/* + * These are cpu model features we want to advertise. The order here + * matters as this is the order in which qmp_query_cpu_model_expansion + * will attempt to set them. If there are dependencies between features, + * then the order that considers those dependencies must be used. + */ +static const char *cpu_model_advertised_features[] = { + "aarch64", "pmu", + NULL +}; + +CpuModelExpansionInfo *qmp_query_cpu_model_expansion(CpuModelExpansionType type, + CpuModelInfo *model, + Error **errp) +{ + CpuModelExpansionInfo *expansion_info; + const QDict *qdict_in = NULL; + QDict *qdict_out; + ObjectClass *oc; + Object *obj; + const char *name; + int i; + + if (type != CPU_MODEL_EXPANSION_TYPE_FULL) { + error_setg(errp, "The requested expansion type is not supported"); + return NULL; + } + + if (!kvm_enabled() && !strcmp(model->name, "host")) { + error_setg(errp, "The CPU type '%s' requires KVM", model->name); + return NULL; + } + + oc = cpu_class_by_name(TYPE_ARM_CPU, model->name); + if (!oc) { + error_setg(errp, "The CPU type '%s' is not a recognized ARM CPU type", + model->name); + return NULL; + } + + if (kvm_enabled()) { + const char *cpu_type = current_machine->cpu_type; + int len = strlen(cpu_type) - strlen(ARM_CPU_TYPE_SUFFIX); + bool supported = false; + + if (!strcmp(model->name, "host") || !strcmp(model->name, "max")) { + /* These are kvmarm's recommended cpu types */ + supported = true; + } else if (strlen(model->name) == len && + !strncmp(model->name, cpu_type, len)) { + /* KVM is enabled and we're using this type, so it works. */ + supported = true; + } + if (!supported) { + error_setg(errp, "We cannot guarantee the CPU type '%s' works " + "with KVM on this host", model->name); + return NULL; + } + } + + if (model->props) { + qdict_in = qobject_to(QDict, model->props); + if (!qdict_in) { + error_setg(errp, QERR_INVALID_PARAMETER_TYPE, "props", "dict"); + return NULL; + } + } + + obj = object_new(object_class_get_name(oc)); + + if (qdict_in) { + Visitor *visitor; + Error *err = NULL; + + visitor = qobject_input_visitor_new(model->props); + visit_start_struct(visitor, NULL, NULL, 0, &err); + if (err) { + visit_free(visitor); + object_unref(obj); + error_propagate(errp, err); + return NULL; + } + + i = 0; + while ((name = cpu_model_advertised_features[i++]) != NULL) { + if (qdict_get(qdict_in, name)) { + object_property_set(obj, visitor, name, &err); + if (err) { + break; + } + } + } + + if (!err) { + visit_check_struct(visitor, &err); + } + visit_end_struct(visitor, NULL); + visit_free(visitor); + if (err) { + object_unref(obj); + error_propagate(errp, err); + return NULL; + } + } + + expansion_info = g_new0(CpuModelExpansionInfo, 1); + expansion_info->model = g_malloc0(sizeof(*expansion_info->model)); + expansion_info->model->name = g_strdup(model->name); + + qdict_out = qdict_new(); + + i = 0; + while ((name = cpu_model_advertised_features[i++]) != NULL) { + ObjectProperty *prop = object_property_find(obj, name, NULL); + if (prop) { + Error *err = NULL; + QObject *value; + + assert(prop->get); + value = object_property_get_qobject(obj, name, &err); + assert(!err); + + qdict_put_obj(qdict_out, name, value); + } + } + + if (!qdict_size(qdict_out)) { + qobject_unref(qdict_out); + } else { + expansion_info->model->props = QOBJECT(qdict_out); + expansion_info->model->has_props = true; + } + + object_unref(obj); + + return expansion_info; +} diff --git a/docs/arm-cpu-features.rst b/docs/arm-cpu-features.rst new file mode 100644 index 00000000000..c79dcffb555 --- /dev/null +++ b/docs/arm-cpu-features.rst @@ -0,0 +1,137 @@ +================ +ARM CPU Features +================ + +Examples of probing and using ARM CPU features + +Introduction +============ + +CPU features are optional features that a CPU of supporting type may +choose to implement or not. In QEMU, optional CPU features have +corresponding boolean CPU proprieties that, when enabled, indicate +that the feature is implemented, and, conversely, when disabled, +indicate that it is not implemented. An example of an ARM CPU feature +is the Performance Monitoring Unit (PMU). CPU types such as the +Cortex-A15 and the Cortex-A57, which respectively implement ARM +architecture reference manuals ARMv7-A and ARMv8-A, may both optionally +implement PMUs. For example, if a user wants to use a Cortex-A15 without +a PMU, then the `-cpu` parameter should contain `pmu=off` on the QEMU +command line, i.e. `-cpu cortex-a15,pmu=off`. + +As not all CPU types support all optional CPU features, then whether or +not a CPU property exists depends on the CPU type. For example, CPUs +that implement the ARMv8-A architecture reference manual may optionally +support the AArch32 CPU feature, which may be enabled by disabling the +`aarch64` CPU property. A CPU type such as the Cortex-A15, which does +not implement ARMv8-A, will not have the `aarch64` CPU property. + +QEMU's support may be limited for some CPU features, only partially +supporting the feature or only supporting the feature under certain +configurations. For example, the `aarch64` CPU feature, which, when +disabled, enables the optional AArch32 CPU feature, is only supported +when using the KVM accelerator and when running on a host CPU type that +supports the feature. + +CPU Feature Probing +=================== + +Determining which CPU features are available and functional for a given +CPU type is possible with the `query-cpu-model-expansion` QMP command. +Below are some examples where `scripts/qmp/qmp-shell` (see the top comment +block in the script for usage) is used to issue the QMP commands. + +(1) Determine which CPU features are available for the `max` CPU type + (Note, we started QEMU with qemu-system-aarch64, so `max` is + implementing the ARMv8-A reference manual in this case):: + + (QEMU) query-cpu-model-expansion type=full model={"name":"max"} + { "return": { + "model": { "name": "max", "props": { + "pmu": true, "aarch64": true + }}}} + +We see that the `max` CPU type has the `pmu` and `aarch64` CPU features. +We also see that the CPU features are enabled, as they are all `true`. + +(2) Let's try to disable the PMU:: + + (QEMU) query-cpu-model-expansion type=full model={"name":"max","props":{"pmu":false}} + { "return": { + "model": { "name": "max", "props": { + "pmu": false, "aarch64": true + }}}} + +We see it worked, as `pmu` is now `false`. + +(3) Let's try to disable `aarch64`, which enables the AArch32 CPU feature:: + + (QEMU) query-cpu-model-expansion type=full model={"name":"max","props":{"aarch64":false}} + {"error": { + "class": "GenericError", "desc": + "'aarch64' feature cannot be disabled unless KVM is enabled and 32-bit EL1 is supported" + }} + +It looks like this feature is limited to a configuration we do not +currently have. + +(4) Let's try probing CPU features for the Cortex-A15 CPU type:: + + (QEMU) query-cpu-model-expansion type=full model={"name":"cortex-a15"} + {"return": {"model": {"name": "cortex-a15", "props": {"pmu": true}}}} + +Only the `pmu` CPU feature is available. + +A note about CPU feature dependencies +------------------------------------- + +It's possible for features to have dependencies on other features. I.e. +it may be possible to change one feature at a time without error, but +when attempting to change all features at once an error could occur +depending on the order they are processed. It's also possible changing +all at once doesn't generate an error, because a feature's dependencies +are satisfied with other features, but the same feature cannot be changed +independently without error. For these reasons callers should always +attempt to make their desired changes all at once in order to ensure the +collection is valid. + +A note about CPU models and KVM +------------------------------- + +Named CPU models generally do not work with KVM. There are a few cases +that do work, e.g. using the named CPU model `cortex-a57` with KVM on a +seattle host, but mostly if KVM is enabled the `host` CPU type must be +used. This means the guest is provided all the same CPU features as the +host CPU type has. And, for this reason, the `host` CPU type should +enable all CPU features that the host has by default. Indeed it's even +a bit strange to allow disabling CPU features that the host has when using +the `host` CPU type, but in the absence of CPU models it's the best we can +do if we want to launch guests without all the host's CPU features enabled. + +Enabling KVM also affects the `query-cpu-model-expansion` QMP command. The +affect is not only limited to specific features, as pointed out in example +(3) of "CPU Feature Probing", but also to which CPU types may be expanded. +When KVM is enabled, only the `max`, `host`, and current CPU type may be +expanded. This restriction is necessary as it's not possible to know all +CPU types that may work with KVM, but it does impose a small risk of users +experiencing unexpected errors. For example on a seattle, as mentioned +above, the `cortex-a57` CPU type is also valid when KVM is enabled. +Therefore a user could use the `host` CPU type for the current type, but +then attempt to query `cortex-a57`, however that query will fail with our +restrictions. This shouldn't be an issue though as management layers and +users have been preferring the `host` CPU type for use with KVM for quite +some time. Additionally, if the KVM-enabled QEMU instance running on a +seattle host is using the `cortex-a57` CPU type, then querying `cortex-a57` +will work. + +Using CPU Features +================== + +After determining which CPU features are available and supported for a +given CPU type, then they may be selectively enabled or disabled on the +QEMU command line with that CPU type:: + + $ qemu-system-aarch64 -M virt -cpu max,pmu=off + +The example above disables the PMU for the `max` CPU type. + From patchwork Thu Oct 24 16:27:09 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 11210529 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 27558139A for ; Thu, 24 Oct 2019 17:24:01 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9B83F20659 for ; Thu, 24 Oct 2019 17:24:00 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="FrbNTW8k" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9B83F20659 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:48646 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNgq6-0000bx-T4 for patchwork-qemu-devel@patchwork.kernel.org; Thu, 24 Oct 2019 13:23:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58180) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNfyB-00084g-8C for qemu-devel@nongnu.org; Thu, 24 Oct 2019 12:28:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iNfy9-000103-9l for qemu-devel@nongnu.org; Thu, 24 Oct 2019 12:28:15 -0400 Received: from mail-wr1-x432.google.com ([2a00:1450:4864:20::432]:34424) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iNfy9-0000ze-2E for qemu-devel@nongnu.org; Thu, 24 Oct 2019 12:28:13 -0400 Received: by mail-wr1-x432.google.com with SMTP id t16so21672585wrr.1 for ; Thu, 24 Oct 2019 09:28:13 -0700 (PDT) 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=1ppvb5bxHlUarLcdtxXV3E1gkwxQBUxp+2P7V8J9BmA=; b=FrbNTW8kPH2/+8FuqoRH5jHzrzyhFI36zkldr5BkVH52m+hv9r9/Li3pHgXIijtc3t MOIrzLegS9liLAZPGpMlAWleXVAd5b1wTqO1SiIAwUQ1EgrERRnHEPzkqDjkeN4r8nVo cp1r7GZyYuTHfvEpk7iIKAUgohFmFMyRJYvcOLa8YMgKQcAqP1Eul72P9tXnvBQQEVFr +Wiqp4V3S9EiSgsbVWWtzVQdzlFLfC4mx7bINPk5A+EvO2BUVRG+Bne7EkHMmeORRwAM XvL32Kp0i+u8LRPpql3zbJzHaxH19PBhteHZG937ClHm6eivDTmSEQHmVtxjoCI33OxW S2iA== 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=1ppvb5bxHlUarLcdtxXV3E1gkwxQBUxp+2P7V8J9BmA=; b=RNse6/aoCHwpulfliJ3ydHPxJRmPb57jxN4fa2tDqSxIOwMNB8x120BU4JbGh4TiBV 7W+ic0gir3CltXPn30BCS5df4aT+IT4ARFRUgMu5WAf1m5EIwTHvyRmQAeggUP9A4zw5 eCv0rpmTrxYSvmy2DQyzGnbkGmgPNWr8RuaxK44Y0c4eD3TU0SsoeIuvfYhi/1VirUJ6 BA05wgKH3eKk427Bq7Ehcm07vIVEfVhn/5WuVCNjPCI+5lKNmj4N6vJxmDVkx0UKOm1G BL5Y69yGMLzW5qsmMYxud9mbTH+yyrszdBPPKhxpNat/uYe7V8ZHf8R4YJxq+VxRDqY2 6mRg== X-Gm-Message-State: APjAAAXJFtyeNTTsAAnXl6EExEX9m6EZVgOP/+YAjge1u/0fZQXR+AOu USpnPitzaguafKLqDanaPudmn5aP15w= X-Google-Smtp-Source: APXvYqxAbeRZ8WMdYcCthF1CDavoKNw1sRkdCXJ+dovoGHNbR4OPkNL6H7qrMkwq/E9AgcVNcicgKg== X-Received: by 2002:adf:e7c9:: with SMTP id e9mr4595384wrn.261.1571934491718; Thu, 24 Oct 2019 09:28:11 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id r27sm42606124wrc.55.2019.10.24.09.28.10 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Oct 2019 09:28:10 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 36/51] tests: arm: Introduce cpu feature tests Date: Thu, 24 Oct 2019 17:27:09 +0100 Message-Id: <20191024162724.31675-37-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191024162724.31675-1-peter.maydell@linaro.org> References: <20191024162724.31675-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 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" From: Andrew Jones Now that Arm CPUs have advertised features lets add tests to ensure we maintain their expected availability with and without KVM. Signed-off-by: Andrew Jones Reviewed-by: Eric Auger Message-id: 20191024121808.9612-3-drjones@redhat.com Signed-off-by: Peter Maydell --- tests/Makefile.include | 5 +- tests/arm-cpu-features.c | 240 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 244 insertions(+), 1 deletion(-) create mode 100644 tests/arm-cpu-features.c diff --git a/tests/Makefile.include b/tests/Makefile.include index 09e5b410dca..d71188f251b 100644 --- a/tests/Makefile.include +++ b/tests/Makefile.include @@ -262,6 +262,7 @@ check-qtest-sparc64-$(CONFIG_ISA_TESTDEV) = tests/endianness-test$(EXESUF) check-qtest-sparc64-y += tests/prom-env-test$(EXESUF) check-qtest-sparc64-y += tests/boot-serial-test$(EXESUF) +check-qtest-arm-y += tests/arm-cpu-features$(EXESUF) check-qtest-arm-y += tests/microbit-test$(EXESUF) check-qtest-arm-y += tests/m25p80-test$(EXESUF) check-qtest-arm-y += tests/test-arm-mptimer$(EXESUF) @@ -269,7 +270,8 @@ check-qtest-arm-y += tests/boot-serial-test$(EXESUF) check-qtest-arm-y += tests/hexloader-test$(EXESUF) check-qtest-arm-$(CONFIG_PFLASH_CFI02) += tests/pflash-cfi02-test$(EXESUF) -check-qtest-aarch64-y = tests/numa-test$(EXESUF) +check-qtest-aarch64-y += tests/arm-cpu-features$(EXESUF) +check-qtest-aarch64-y += tests/numa-test$(EXESUF) check-qtest-aarch64-y += tests/boot-serial-test$(EXESUF) check-qtest-aarch64-y += tests/migration-test$(EXESUF) # TODO: once aarch64 TCG is fixed on ARM 32 bit host, make test unconditional @@ -835,6 +837,7 @@ tests/test-qapi-util$(EXESUF): tests/test-qapi-util.o $(test-util-obj-y) tests/numa-test$(EXESUF): tests/numa-test.o tests/vmgenid-test$(EXESUF): tests/vmgenid-test.o tests/boot-sector.o tests/acpi-utils.o tests/cdrom-test$(EXESUF): tests/cdrom-test.o tests/boot-sector.o $(libqos-obj-y) +tests/arm-cpu-features$(EXESUF): tests/arm-cpu-features.o tests/migration/stress$(EXESUF): tests/migration/stress.o $(call quiet-command, $(LINKPROG) -static -O3 $(PTHREAD_LIB) -o $@ $< ,"LINK","$(TARGET_DIR)$@") diff --git a/tests/arm-cpu-features.c b/tests/arm-cpu-features.c new file mode 100644 index 00000000000..c59fcf409c8 --- /dev/null +++ b/tests/arm-cpu-features.c @@ -0,0 +1,240 @@ +/* + * Arm CPU feature test cases + * + * Copyright (c) 2019 Red Hat Inc. + * Authors: + * Andrew Jones + * + * This work is licensed under the terms of the GNU GPL, version 2 or later. + * See the COPYING file in the top-level directory. + */ +#include "qemu/osdep.h" +#include "libqtest.h" +#include "qapi/qmp/qdict.h" +#include "qapi/qmp/qjson.h" + +#define MACHINE "-machine virt,gic-version=max " +#define QUERY_HEAD "{ 'execute': 'query-cpu-model-expansion', " \ + "'arguments': { 'type': 'full', " +#define QUERY_TAIL "}}" + +static QDict *do_query_no_props(QTestState *qts, const char *cpu_type) +{ + return qtest_qmp(qts, QUERY_HEAD "'model': { 'name': %s }" + QUERY_TAIL, cpu_type); +} + +static QDict *do_query(QTestState *qts, const char *cpu_type, + const char *fmt, ...) +{ + QDict *resp; + + if (fmt) { + QDict *args; + va_list ap; + + va_start(ap, fmt); + args = qdict_from_vjsonf_nofail(fmt, ap); + va_end(ap); + + resp = qtest_qmp(qts, QUERY_HEAD "'model': { 'name': %s, " + "'props': %p }" + QUERY_TAIL, cpu_type, args); + } else { + resp = do_query_no_props(qts, cpu_type); + } + + return resp; +} + +static const char *resp_get_error(QDict *resp) +{ + QDict *qdict; + + g_assert(resp); + + qdict = qdict_get_qdict(resp, "error"); + if (qdict) { + return qdict_get_str(qdict, "desc"); + } + return NULL; +} + +#define assert_error(qts, cpu_type, expected_error, fmt, ...) \ +({ \ + QDict *_resp; \ + const char *_error; \ + \ + _resp = do_query(qts, cpu_type, fmt, ##__VA_ARGS__); \ + g_assert(_resp); \ + _error = resp_get_error(_resp); \ + g_assert(_error); \ + g_assert(g_str_equal(_error, expected_error)); \ + qobject_unref(_resp); \ +}) + +static bool resp_has_props(QDict *resp) +{ + QDict *qdict; + + g_assert(resp); + + if (!qdict_haskey(resp, "return")) { + return false; + } + qdict = qdict_get_qdict(resp, "return"); + + if (!qdict_haskey(qdict, "model")) { + return false; + } + qdict = qdict_get_qdict(qdict, "model"); + + return qdict_haskey(qdict, "props"); +} + +static QDict *resp_get_props(QDict *resp) +{ + QDict *qdict; + + g_assert(resp); + g_assert(resp_has_props(resp)); + + qdict = qdict_get_qdict(resp, "return"); + qdict = qdict_get_qdict(qdict, "model"); + qdict = qdict_get_qdict(qdict, "props"); + return qdict; +} + +#define assert_has_feature(qts, cpu_type, feature) \ +({ \ + QDict *_resp = do_query_no_props(qts, cpu_type); \ + g_assert(_resp); \ + g_assert(resp_has_props(_resp)); \ + g_assert(qdict_get(resp_get_props(_resp), feature)); \ + qobject_unref(_resp); \ +}) + +#define assert_has_not_feature(qts, cpu_type, feature) \ +({ \ + QDict *_resp = do_query_no_props(qts, cpu_type); \ + g_assert(_resp); \ + g_assert(!resp_has_props(_resp) || \ + !qdict_get(resp_get_props(_resp), feature)); \ + qobject_unref(_resp); \ +}) + +static void assert_type_full(QTestState *qts) +{ + const char *error; + QDict *resp; + + resp = qtest_qmp(qts, "{ 'execute': 'query-cpu-model-expansion', " + "'arguments': { 'type': 'static', " + "'model': { 'name': 'foo' }}}"); + g_assert(resp); + error = resp_get_error(resp); + g_assert(error); + g_assert(g_str_equal(error, + "The requested expansion type is not supported")); + qobject_unref(resp); +} + +static void assert_bad_props(QTestState *qts, const char *cpu_type) +{ + const char *error; + QDict *resp; + + resp = qtest_qmp(qts, "{ 'execute': 'query-cpu-model-expansion', " + "'arguments': { 'type': 'full', " + "'model': { 'name': %s, " + "'props': false }}}", + cpu_type); + g_assert(resp); + error = resp_get_error(resp); + g_assert(error); + g_assert(g_str_equal(error, + "Invalid parameter type for 'props', expected: dict")); + qobject_unref(resp); +} + +static void test_query_cpu_model_expansion(const void *data) +{ + QTestState *qts; + + qts = qtest_init(MACHINE "-cpu max"); + + /* Test common query-cpu-model-expansion input validation */ + assert_type_full(qts); + assert_bad_props(qts, "max"); + assert_error(qts, "foo", "The CPU type 'foo' is not a recognized " + "ARM CPU type", NULL); + assert_error(qts, "max", "Parameter 'not-a-prop' is unexpected", + "{ 'not-a-prop': false }"); + assert_error(qts, "host", "The CPU type 'host' requires KVM", NULL); + + /* Test expected feature presence/absence for some cpu types */ + assert_has_feature(qts, "max", "pmu"); + assert_has_feature(qts, "cortex-a15", "pmu"); + assert_has_not_feature(qts, "cortex-a15", "aarch64"); + + if (g_str_equal(qtest_get_arch(), "aarch64")) { + assert_has_feature(qts, "max", "aarch64"); + assert_has_feature(qts, "cortex-a57", "pmu"); + assert_has_feature(qts, "cortex-a57", "aarch64"); + + /* Test that features that depend on KVM generate errors without. */ + assert_error(qts, "max", + "'aarch64' feature cannot be disabled " + "unless KVM is enabled and 32-bit EL1 " + "is supported", + "{ 'aarch64': false }"); + } + + qtest_quit(qts); +} + +static void test_query_cpu_model_expansion_kvm(const void *data) +{ + QTestState *qts; + + qts = qtest_init(MACHINE "-accel kvm -cpu host"); + + if (g_str_equal(qtest_get_arch(), "aarch64")) { + assert_has_feature(qts, "host", "aarch64"); + assert_has_feature(qts, "host", "pmu"); + + assert_error(qts, "cortex-a15", + "We cannot guarantee the CPU type 'cortex-a15' works " + "with KVM on this host", NULL); + } else { + assert_has_not_feature(qts, "host", "aarch64"); + assert_has_not_feature(qts, "host", "pmu"); + } + + qtest_quit(qts); +} + +int main(int argc, char **argv) +{ + bool kvm_available = false; + + if (!access("/dev/kvm", R_OK | W_OK)) { +#if defined(HOST_AARCH64) + kvm_available = g_str_equal(qtest_get_arch(), "aarch64"); +#elif defined(HOST_ARM) + kvm_available = g_str_equal(qtest_get_arch(), "arm"); +#endif + } + + g_test_init(&argc, &argv, NULL); + + qtest_add_data_func("/arm/query-cpu-model-expansion", + NULL, test_query_cpu_model_expansion); + + if (kvm_available) { + qtest_add_data_func("/arm/kvm/query-cpu-model-expansion", + NULL, test_query_cpu_model_expansion_kvm); + } + + return g_test_run(); +} From patchwork Thu Oct 24 16:27:10 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 11210477 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C0867112C for ; Thu, 24 Oct 2019 17:13:54 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 95D7720650 for ; Thu, 24 Oct 2019 17:13:54 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="zgdQDlmI" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 95D7720650 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:48428 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNggL-0000TR-6M for patchwork-qemu-devel@patchwork.kernel.org; Thu, 24 Oct 2019 13:13:53 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58189) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNfyC-00086i-7e for qemu-devel@nongnu.org; Thu, 24 Oct 2019 12:28:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iNfyA-00010U-LQ for qemu-devel@nongnu.org; Thu, 24 Oct 2019 12:28:16 -0400 Received: from mail-wm1-x32f.google.com ([2a00:1450:4864:20::32f]:52278) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iNfyA-00010A-Dy for qemu-devel@nongnu.org; Thu, 24 Oct 2019 12:28:14 -0400 Received: by mail-wm1-x32f.google.com with SMTP id p21so2100866wmg.2 for ; Thu, 24 Oct 2019 09:28:14 -0700 (PDT) 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=YX5kAV2V+51rIRAoIJH8dk7lXcJe17TkZW9vBLdbmdY=; b=zgdQDlmI2ot3n40f+DLOr+5xsOXSL/83GFPGtC7ZlYuqaVhTwCEN/nsMk+emHyS0Dc Ek6nzWFKjzxJRB14MvNmM3gcUHk1Wri1xIlBmHgvPLqkbk+7Qfvxnxk/YFRtRSUpxlWu /cMA+jm+Tds5TSuVuIMXMjskRctXVkIhXz60J5pPE1dDzOBxAGIjW6fPwZNsvTpccb6o SXb/oW2oflRqc4OA/MxBs557+2fTMfSR8OJ8OUvhRKDoDhs9u3tuZVnP9xlEiiuOeonN 1elnCEkS1rty0hBzNOFtrlalDlrHusd98zFdK1VOdE3c7x1GPp+cNvtGzdRlrSvh9MNa M1fQ== 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=YX5kAV2V+51rIRAoIJH8dk7lXcJe17TkZW9vBLdbmdY=; b=hpzleNZ/Rp9F58OfivcQcisRnZeZO53fRwuixJ7RYyURYwSEMt0D3nwW+hLuecbpYO kYPQlaq6EydWnKhxqyUs9qGt58URE5WIlly0hjPX2tI3XRuMp3/SWG6RjxgT8hnMWK2k ebUQgiOJ9k7KstzbcjGhTcRQf6kLcrJ4lVs0nVBU19vF1DCqmp+2V+1eFOEHB8vWRCdD 1iblvweO7owbnWpiaHvpYR+u+/n5ze7VQltLDEGe/X9wFhi9hqQ/MM7aRV3wsx/S3zXF gX8kJYVgzjYkc8TqHoo5J5r5MMQh/0A9lJreoi2chNsP4qVP62/ZqN+R1RSnuoJLgqxA oLqA== X-Gm-Message-State: APjAAAVonriTWatGcBa4/vy24WoQmmSautAhhkI845HSfpEM20LLHSg1 XX2K5Lq5uwSbIjAJRLT4gwDuTpyr6VE= X-Google-Smtp-Source: APXvYqxfa0RjSE0fKc2ugPraEPK85a0Cgrck4/0stnzaaDlAznGAWeAssdKk6AdHEC5KkL2e03AFgw== X-Received: by 2002:a1c:5587:: with SMTP id j129mr5669423wmb.15.1571934492938; Thu, 24 Oct 2019 09:28:12 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id r27sm42606124wrc.55.2019.10.24.09.28.11 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Oct 2019 09:28:12 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 37/51] target/arm: Allow SVE to be disabled via a CPU property Date: Thu, 24 Oct 2019 17:27:10 +0100 Message-Id: <20191024162724.31675-38-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191024162724.31675-1-peter.maydell@linaro.org> References: <20191024162724.31675-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::32f X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" From: Andrew Jones Since 97a28b0eeac14 ("target/arm: Allow VFP and Neon to be disabled via a CPU property") we can disable the 'max' cpu model's VFP and neon features, but there's no way to disable SVE. Add the 'sve=on|off' property to give it that flexibility. We also rename cpu_max_get/set_sve_vq to cpu_max_get/set_sve_max_vq in order for them to follow the typical *_get/set_ pattern. Signed-off-by: Andrew Jones Reviewed-by: Richard Henderson Reviewed-by: Eric Auger Tested-by: Masayoshi Mizuma Reviewed-by: Beata Michalska Message-id: 20191024121808.9612-4-drjones@redhat.com Signed-off-by: Peter Maydell --- target/arm/cpu.c | 3 ++- target/arm/cpu64.c | 52 ++++++++++++++++++++++++++++++++++------ target/arm/monitor.c | 2 +- tests/arm-cpu-features.c | 1 + 4 files changed, 49 insertions(+), 9 deletions(-) diff --git a/target/arm/cpu.c b/target/arm/cpu.c index ab3e1a03616..72a27ec4b0e 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -200,7 +200,8 @@ static void arm_cpu_reset(CPUState *s) env->cp15.cpacr_el1 = deposit64(env->cp15.cpacr_el1, 16, 2, 3); env->cp15.cptr_el[3] |= CPTR_EZ; /* with maximum vector length */ - env->vfp.zcr_el[1] = cpu->sve_max_vq - 1; + env->vfp.zcr_el[1] = cpu_isar_feature(aa64_sve, cpu) ? + cpu->sve_max_vq - 1 : 0; env->vfp.zcr_el[2] = env->vfp.zcr_el[1]; env->vfp.zcr_el[3] = env->vfp.zcr_el[1]; /* diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c index d7f5bf610a7..89a8ae77fe8 100644 --- a/target/arm/cpu64.c +++ b/target/arm/cpu64.c @@ -256,15 +256,23 @@ static void aarch64_a72_initfn(Object *obj) define_arm_cp_regs(cpu, cortex_a72_a57_a53_cp_reginfo); } -static void cpu_max_get_sve_vq(Object *obj, Visitor *v, const char *name, - void *opaque, Error **errp) +static void cpu_max_get_sve_max_vq(Object *obj, Visitor *v, const char *name, + void *opaque, Error **errp) { ARMCPU *cpu = ARM_CPU(obj); - visit_type_uint32(v, name, &cpu->sve_max_vq, errp); + uint32_t value; + + /* All vector lengths are disabled when SVE is off. */ + if (!cpu_isar_feature(aa64_sve, cpu)) { + value = 0; + } else { + value = cpu->sve_max_vq; + } + visit_type_uint32(v, name, &value, errp); } -static void cpu_max_set_sve_vq(Object *obj, Visitor *v, const char *name, - void *opaque, Error **errp) +static void cpu_max_set_sve_max_vq(Object *obj, Visitor *v, const char *name, + void *opaque, Error **errp) { ARMCPU *cpu = ARM_CPU(obj); Error *err = NULL; @@ -279,6 +287,34 @@ static void cpu_max_set_sve_vq(Object *obj, Visitor *v, const char *name, error_propagate(errp, err); } +static void cpu_arm_get_sve(Object *obj, Visitor *v, const char *name, + void *opaque, Error **errp) +{ + ARMCPU *cpu = ARM_CPU(obj); + bool value = cpu_isar_feature(aa64_sve, cpu); + + visit_type_bool(v, name, &value, errp); +} + +static void cpu_arm_set_sve(Object *obj, Visitor *v, const char *name, + void *opaque, Error **errp) +{ + ARMCPU *cpu = ARM_CPU(obj); + Error *err = NULL; + bool value; + uint64_t t; + + visit_type_bool(v, name, &value, &err); + if (err) { + error_propagate(errp, err); + return; + } + + t = cpu->isar.id_aa64pfr0; + t = FIELD_DP64(t, ID_AA64PFR0, SVE, value); + cpu->isar.id_aa64pfr0 = t; +} + /* -cpu max: if KVM is enabled, like -cpu host (best possible with this host); * otherwise, a CPU with as many features enabled as our emulation supports. * The version of '-cpu max' for qemu-system-arm is defined in cpu.c; @@ -391,8 +427,10 @@ static void aarch64_max_initfn(Object *obj) #endif cpu->sve_max_vq = ARM_MAX_VQ; - object_property_add(obj, "sve-max-vq", "uint32", cpu_max_get_sve_vq, - cpu_max_set_sve_vq, NULL, NULL, &error_fatal); + object_property_add(obj, "sve-max-vq", "uint32", cpu_max_get_sve_max_vq, + cpu_max_set_sve_max_vq, NULL, NULL, &error_fatal); + object_property_add(obj, "sve", "bool", cpu_arm_get_sve, + cpu_arm_set_sve, NULL, NULL, &error_fatal); } } diff --git a/target/arm/monitor.c b/target/arm/monitor.c index 560970de7f5..2209b27b9a0 100644 --- a/target/arm/monitor.c +++ b/target/arm/monitor.c @@ -97,7 +97,7 @@ GICCapabilityList *qmp_query_gic_capabilities(Error **errp) * then the order that considers those dependencies must be used. */ static const char *cpu_model_advertised_features[] = { - "aarch64", "pmu", + "aarch64", "pmu", "sve", NULL }; diff --git a/tests/arm-cpu-features.c b/tests/arm-cpu-features.c index c59fcf409c8..6342cd2e4ec 100644 --- a/tests/arm-cpu-features.c +++ b/tests/arm-cpu-features.c @@ -179,6 +179,7 @@ static void test_query_cpu_model_expansion(const void *data) if (g_str_equal(qtest_get_arch(), "aarch64")) { assert_has_feature(qts, "max", "aarch64"); + assert_has_feature(qts, "max", "sve"); assert_has_feature(qts, "cortex-a57", "pmu"); assert_has_feature(qts, "cortex-a57", "aarch64"); From patchwork Thu Oct 24 16:27:11 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 11210539 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 10EDC139A for ; Thu, 24 Oct 2019 17:27:38 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id C83B9205F4 for ; Thu, 24 Oct 2019 17:27:37 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="WhJbq2xi" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C83B9205F4 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:48724 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNgtc-0007in-H0 for patchwork-qemu-devel@patchwork.kernel.org; Thu, 24 Oct 2019 13:27:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58245) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNfyI-0008HN-BT for qemu-devel@nongnu.org; Thu, 24 Oct 2019 12:28:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iNfyE-00011f-6q for qemu-devel@nongnu.org; Thu, 24 Oct 2019 12:28:22 -0400 Received: from mail-wm1-x335.google.com ([2a00:1450:4864:20::335]:55110) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iNfyC-00011D-Ry for qemu-devel@nongnu.org; Thu, 24 Oct 2019 12:28:18 -0400 Received: by mail-wm1-x335.google.com with SMTP id g7so3537260wmk.4 for ; Thu, 24 Oct 2019 09:28:16 -0700 (PDT) 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=a3E4jS/ojygIRXGs7ta8idsyXZSz+sc9Y9b47EiXEPY=; b=WhJbq2xi4pxXya2yG8wHOfibGcjW98oM0ae01DHNTwJly4HBxNLXSMjeAQd+r71vmA Av5ltt519VuRyrxq0xhNJ7oPRWvYBskc26xsXO5yYY4/YY6Rw8yLy5/+xE0Xe0OmN8w1 M1d6Za/wOdkmFBxAd9f+Bw2DRPC9ZERaHTjM4wDcCrUk0R6aukbchL5wFqbUTwUD4qDE VWpnKW4jVUN0kkg0CgWnS2S2HLy/p57YF7hXZXrIU4sIt9AzTeF9QuiPOHPdztWMiEOh tb4UrvLuoQRbPiBDG1Fe7H5I5bDt8VmPhA5ZJKTaMRcbOrf9cuMc2eUt9HwvQsgUVa0Q weSg== 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=a3E4jS/ojygIRXGs7ta8idsyXZSz+sc9Y9b47EiXEPY=; b=WpHYTfyXyUXk+v5hSCsg/C0AmAl9GI3Fj2tPpFUmfufKLTKcvLie37zB8w+5f4IyUg ihZrLj6xYXb1V5h8t8vJDfC4WZj6K+TSM+WTagW6mjIqSD6wJwTcOk/z2fy1iUF+C9qg bKk8ErDh+0r1LlppExuRvtH7blegj/T3OBcKQt0yeUU856ZNQkBrTbR+Hw2u09ZurEnS Zjds1ZSrj2xYjfHm31yX1wkwhGaQxBWxP5PJmrX3Ibg2KHdjkbDEPbziU7+rlIljCGH9 Yczqa4Kl+X1EhEinSyMI9Dg/hcdncyxWFBWItX0oqd4fzS75soKIcfUUUZ3TpsKrH0LG yjhw== X-Gm-Message-State: APjAAAWLuWOsBqK6GhaQ3ufNeSe+xPmdyyTPLull8SmB2uRja3yucP8Y 3yMqYq3jgZPr3/KC03OYWirD5oH2hZI= X-Google-Smtp-Source: APXvYqxi/AAM3UbyLAyh9Bc0HDiVP/MzrogG3qwGP6Sj4WN30WhfgbxRVZiHvNERNGvv9aqwBNwvow== X-Received: by 2002:a1c:7917:: with SMTP id l23mr5275419wme.60.1571934494645; Thu, 24 Oct 2019 09:28:14 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id r27sm42606124wrc.55.2019.10.24.09.28.13 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Oct 2019 09:28:13 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 38/51] target/arm/cpu64: max cpu: Introduce sve properties Date: Thu, 24 Oct 2019 17:27:11 +0100 Message-Id: <20191024162724.31675-39-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191024162724.31675-1-peter.maydell@linaro.org> References: <20191024162724.31675-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::335 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" From: Andrew Jones Introduce cpu properties to give fine control over SVE vector lengths. We introduce a property for each valid length up to the current maximum supported, which is 2048-bits. The properties are named, e.g. sve128, sve256, sve384, sve512, ..., where the number is the number of bits. See the updates to docs/arm-cpu-features.rst for a description of the semantics and for example uses. Note, as sve-max-vq is still present and we'd like to be able to support qmp_query_cpu_model_expansion with guests launched with e.g. -cpu max,sve-max-vq=8 on their command lines, then we do allow sve-max-vq and sve properties to be provided at the same time, but this is not recommended, and is why sve-max-vq is not mentioned in the document. If sve-max-vq is provided then it enables all lengths smaller than and including the max and disables all lengths larger. It also has the side-effect that no larger lengths may be enabled and that the max itself cannot be disabled. Smaller non-power-of-two lengths may, however, be disabled, e.g. -cpu max,sve-max-vq=4,sve384=off provides a guest the vector lengths 128, 256, and 512 bits. This patch has been co-authored with Richard Henderson, who reworked the target/arm/cpu64.c changes in order to push all the validation and auto-enabling/disabling steps into the finalizer, resulting in a nice LOC reduction. Signed-off-by: Andrew Jones Reviewed-by: Richard Henderson Reviewed-by: Eric Auger Tested-by: Masayoshi Mizuma Reviewed-by: Beata Michalska Message-id: 20191024121808.9612-5-drjones@redhat.com Signed-off-by: Peter Maydell --- include/qemu/bitops.h | 1 + target/arm/cpu.h | 19 ++++ target/arm/cpu.c | 19 ++++ target/arm/cpu64.c | 192 ++++++++++++++++++++++++++++++++++++- target/arm/helper.c | 10 +- target/arm/monitor.c | 12 +++ tests/arm-cpu-features.c | 194 ++++++++++++++++++++++++++++++++++++++ docs/arm-cpu-features.rst | 168 +++++++++++++++++++++++++++++++-- 8 files changed, 606 insertions(+), 9 deletions(-) diff --git a/include/qemu/bitops.h b/include/qemu/bitops.h index 3f0926cf40c..ee76552c062 100644 --- a/include/qemu/bitops.h +++ b/include/qemu/bitops.h @@ -20,6 +20,7 @@ #define BITS_PER_LONG (sizeof (unsigned long) * BITS_PER_BYTE) #define BIT(nr) (1UL << (nr)) +#define BIT_ULL(nr) (1ULL << (nr)) #define BIT_MASK(nr) (1UL << ((nr) % BITS_PER_LONG)) #define BIT_WORD(nr) ((nr) / BITS_PER_LONG) #define BITS_TO_LONGS(nr) DIV_ROUND_UP(nr, BITS_PER_BYTE * sizeof(long)) diff --git a/target/arm/cpu.h b/target/arm/cpu.h index d844ea21d8d..a044d6028b6 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -184,8 +184,13 @@ typedef struct { #ifdef TARGET_AARCH64 # define ARM_MAX_VQ 16 +void arm_cpu_sve_finalize(ARMCPU *cpu, Error **errp); +uint32_t arm_cpu_vq_map_next_smaller(ARMCPU *cpu, uint32_t vq); #else # define ARM_MAX_VQ 1 +static inline void arm_cpu_sve_finalize(ARMCPU *cpu, Error **errp) { } +static inline uint32_t arm_cpu_vq_map_next_smaller(ARMCPU *cpu, uint32_t vq) +{ return 0; } #endif typedef struct ARMVectorReg { @@ -918,6 +923,18 @@ struct ARMCPU { /* Used to set the maximum vector length the cpu will support. */ uint32_t sve_max_vq; + + /* + * In sve_vq_map each set bit is a supported vector length of + * (bit-number + 1) * 16 bytes, i.e. each bit number + 1 is the vector + * length in quadwords. + * + * While processing properties during initialization, corresponding + * sve_vq_init bits are set for bits in sve_vq_map that have been + * set by properties. + */ + DECLARE_BITMAP(sve_vq_map, ARM_MAX_VQ); + DECLARE_BITMAP(sve_vq_init, ARM_MAX_VQ); }; void arm_cpu_post_init(Object *obj); @@ -1837,6 +1854,8 @@ static inline int arm_feature(CPUARMState *env, int feature) return (env->features & (1ULL << feature)) != 0; } +void arm_cpu_finalize_features(ARMCPU *cpu, Error **errp); + #if !defined(CONFIG_USER_ONLY) /* Return true if exception levels below EL3 are in secure state, * or would be following an exception return to that level. diff --git a/target/arm/cpu.c b/target/arm/cpu.c index 72a27ec4b0e..17d1f2b2894 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -1198,6 +1198,19 @@ static void arm_cpu_finalizefn(Object *obj) #endif } +void arm_cpu_finalize_features(ARMCPU *cpu, Error **errp) +{ + Error *local_err = NULL; + + if (arm_feature(&cpu->env, ARM_FEATURE_AARCH64)) { + arm_cpu_sve_finalize(cpu, &local_err); + if (local_err != NULL) { + error_propagate(errp, local_err); + return; + } + } +} + static void arm_cpu_realizefn(DeviceState *dev, Error **errp) { CPUState *cs = CPU(dev); @@ -1254,6 +1267,12 @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp) return; } + arm_cpu_finalize_features(cpu, &local_err); + if (local_err != NULL) { + error_propagate(errp, local_err); + return; + } + if (arm_feature(env, ARM_FEATURE_AARCH64) && cpu->has_vfp != cpu->has_neon) { /* diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c index 89a8ae77fe8..34b0ba2cf6f 100644 --- a/target/arm/cpu64.c +++ b/target/arm/cpu64.c @@ -256,6 +256,151 @@ static void aarch64_a72_initfn(Object *obj) define_arm_cp_regs(cpu, cortex_a72_a57_a53_cp_reginfo); } +void arm_cpu_sve_finalize(ARMCPU *cpu, Error **errp) +{ + /* + * If any vector lengths are explicitly enabled with sve properties, + * then all other lengths are implicitly disabled. If sve-max-vq is + * specified then it is the same as explicitly enabling all lengths + * up to and including the specified maximum, which means all larger + * lengths will be implicitly disabled. If no sve properties + * are enabled and sve-max-vq is not specified, then all lengths not + * explicitly disabled will be enabled. Additionally, all power-of-two + * vector lengths less than the maximum enabled length will be + * automatically enabled and all vector lengths larger than the largest + * disabled power-of-two vector length will be automatically disabled. + * Errors are generated if the user provided input that interferes with + * any of the above. Finally, if SVE is not disabled, then at least one + * vector length must be enabled. + */ + DECLARE_BITMAP(tmp, ARM_MAX_VQ); + uint32_t vq, max_vq = 0; + + /* + * Process explicit sve properties. + * From the properties, sve_vq_map implies sve_vq_init. + * Check first for any sve enabled. + */ + if (!bitmap_empty(cpu->sve_vq_map, ARM_MAX_VQ)) { + max_vq = find_last_bit(cpu->sve_vq_map, ARM_MAX_VQ) + 1; + + if (cpu->sve_max_vq && max_vq > cpu->sve_max_vq) { + error_setg(errp, "cannot enable sve%d", max_vq * 128); + error_append_hint(errp, "sve%d is larger than the maximum vector " + "length, sve-max-vq=%d (%d bits)\n", + max_vq * 128, cpu->sve_max_vq, + cpu->sve_max_vq * 128); + return; + } + + /* Propagate enabled bits down through required powers-of-two. */ + for (vq = pow2floor(max_vq); vq >= 1; vq >>= 1) { + if (!test_bit(vq - 1, cpu->sve_vq_init)) { + set_bit(vq - 1, cpu->sve_vq_map); + } + } + } else if (cpu->sve_max_vq == 0) { + /* + * No explicit bits enabled, and no implicit bits from sve-max-vq. + */ + if (!cpu_isar_feature(aa64_sve, cpu)) { + /* SVE is disabled and so are all vector lengths. Good. */ + return; + } + + /* Disabling a power-of-two disables all larger lengths. */ + if (test_bit(0, cpu->sve_vq_init)) { + error_setg(errp, "cannot disable sve128"); + error_append_hint(errp, "Disabling sve128 results in all vector " + "lengths being disabled.\n"); + error_append_hint(errp, "With SVE enabled, at least one vector " + "length must be enabled.\n"); + return; + } + for (vq = 2; vq <= ARM_MAX_VQ; vq <<= 1) { + if (test_bit(vq - 1, cpu->sve_vq_init)) { + break; + } + } + max_vq = vq <= ARM_MAX_VQ ? vq - 1 : ARM_MAX_VQ; + + bitmap_complement(cpu->sve_vq_map, cpu->sve_vq_init, max_vq); + max_vq = find_last_bit(cpu->sve_vq_map, max_vq) + 1; + } + + /* + * Process the sve-max-vq property. + * Note that we know from the above that no bit above + * sve-max-vq is currently set. + */ + if (cpu->sve_max_vq != 0) { + max_vq = cpu->sve_max_vq; + + if (!test_bit(max_vq - 1, cpu->sve_vq_map) && + test_bit(max_vq - 1, cpu->sve_vq_init)) { + error_setg(errp, "cannot disable sve%d", max_vq * 128); + error_append_hint(errp, "The maximum vector length must be " + "enabled, sve-max-vq=%d (%d bits)\n", + max_vq, max_vq * 128); + return; + } + + /* Set all bits not explicitly set within sve-max-vq. */ + bitmap_complement(tmp, cpu->sve_vq_init, max_vq); + bitmap_or(cpu->sve_vq_map, cpu->sve_vq_map, tmp, max_vq); + } + + /* + * We should know what max-vq is now. Also, as we're done + * manipulating sve-vq-map, we ensure any bits above max-vq + * are clear, just in case anybody looks. + */ + assert(max_vq != 0); + bitmap_clear(cpu->sve_vq_map, max_vq, ARM_MAX_VQ - max_vq); + + /* Ensure all required powers-of-two are enabled. */ + for (vq = pow2floor(max_vq); vq >= 1; vq >>= 1) { + if (!test_bit(vq - 1, cpu->sve_vq_map)) { + error_setg(errp, "cannot disable sve%d", vq * 128); + error_append_hint(errp, "sve%d is required as it " + "is a power-of-two length smaller than " + "the maximum, sve%d\n", + vq * 128, max_vq * 128); + return; + } + } + + /* + * Now that we validated all our vector lengths, the only question + * left to answer is if we even want SVE at all. + */ + if (!cpu_isar_feature(aa64_sve, cpu)) { + error_setg(errp, "cannot enable sve%d", max_vq * 128); + error_append_hint(errp, "SVE must be enabled to enable vector " + "lengths.\n"); + error_append_hint(errp, "Add sve=on to the CPU property list.\n"); + return; + } + + /* From now on sve_max_vq is the actual maximum supported length. */ + cpu->sve_max_vq = max_vq; +} + +uint32_t arm_cpu_vq_map_next_smaller(ARMCPU *cpu, uint32_t vq) +{ + uint32_t bitnum; + + /* + * We allow vq == ARM_MAX_VQ + 1 to be input because the caller may want + * to find the maximum vq enabled, which may be ARM_MAX_VQ, but this + * function always returns the next smaller than the input. + */ + assert(vq && vq <= ARM_MAX_VQ + 1); + + bitnum = find_last_bit(cpu->sve_vq_map, vq - 1); + return bitnum == vq - 1 ? 0 : bitnum + 1; +} + static void cpu_max_get_sve_max_vq(Object *obj, Visitor *v, const char *name, void *opaque, Error **errp) { @@ -287,6 +432,44 @@ static void cpu_max_set_sve_max_vq(Object *obj, Visitor *v, const char *name, error_propagate(errp, err); } +static void cpu_arm_get_sve_vq(Object *obj, Visitor *v, const char *name, + void *opaque, Error **errp) +{ + ARMCPU *cpu = ARM_CPU(obj); + uint32_t vq = atoi(&name[3]) / 128; + bool value; + + /* All vector lengths are disabled when SVE is off. */ + if (!cpu_isar_feature(aa64_sve, cpu)) { + value = false; + } else { + value = test_bit(vq - 1, cpu->sve_vq_map); + } + visit_type_bool(v, name, &value, errp); +} + +static void cpu_arm_set_sve_vq(Object *obj, Visitor *v, const char *name, + void *opaque, Error **errp) +{ + ARMCPU *cpu = ARM_CPU(obj); + uint32_t vq = atoi(&name[3]) / 128; + Error *err = NULL; + bool value; + + visit_type_bool(v, name, &value, &err); + if (err) { + error_propagate(errp, err); + return; + } + + if (value) { + set_bit(vq - 1, cpu->sve_vq_map); + } else { + clear_bit(vq - 1, cpu->sve_vq_map); + } + set_bit(vq - 1, cpu->sve_vq_init); +} + static void cpu_arm_get_sve(Object *obj, Visitor *v, const char *name, void *opaque, Error **errp) { @@ -323,6 +506,7 @@ static void cpu_arm_set_sve(Object *obj, Visitor *v, const char *name, static void aarch64_max_initfn(Object *obj) { ARMCPU *cpu = ARM_CPU(obj); + uint32_t vq; if (kvm_enabled()) { kvm_arm_set_cpu_features_from_host(cpu); @@ -426,11 +610,17 @@ static void aarch64_max_initfn(Object *obj) cpu->dcz_blocksize = 7; /* 512 bytes */ #endif - cpu->sve_max_vq = ARM_MAX_VQ; object_property_add(obj, "sve-max-vq", "uint32", cpu_max_get_sve_max_vq, cpu_max_set_sve_max_vq, NULL, NULL, &error_fatal); object_property_add(obj, "sve", "bool", cpu_arm_get_sve, cpu_arm_set_sve, NULL, NULL, &error_fatal); + + for (vq = 1; vq <= ARM_MAX_VQ; ++vq) { + char name[8]; + sprintf(name, "sve%d", vq * 128); + object_property_add(obj, name, "bool", cpu_arm_get_sve_vq, + cpu_arm_set_sve_vq, NULL, NULL, &error_fatal); + } } } diff --git a/target/arm/helper.c b/target/arm/helper.c index 63815fc4cfc..be67e2c66d6 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -5361,6 +5361,13 @@ int sve_exception_el(CPUARMState *env, int el) return 0; } +static uint32_t sve_zcr_get_valid_len(ARMCPU *cpu, uint32_t start_len) +{ + uint32_t start_vq = (start_len & 0xf) + 1; + + return arm_cpu_vq_map_next_smaller(cpu, start_vq + 1) - 1; +} + /* * Given that SVE is enabled, return the vector length for EL. */ @@ -5378,7 +5385,8 @@ uint32_t sve_zcr_len_for_el(CPUARMState *env, int el) if (arm_feature(env, ARM_FEATURE_EL3)) { zcr_len = MIN(zcr_len, 0xf & (uint32_t)env->vfp.zcr_el[3]); } - return zcr_len; + + return sve_zcr_get_valid_len(cpu, zcr_len); } static void zcr_write(CPUARMState *env, const ARMCPRegInfo *ri, diff --git a/target/arm/monitor.c b/target/arm/monitor.c index 2209b27b9a0..fa054f8a369 100644 --- a/target/arm/monitor.c +++ b/target/arm/monitor.c @@ -90,6 +90,8 @@ GICCapabilityList *qmp_query_gic_capabilities(Error **errp) return head; } +QEMU_BUILD_BUG_ON(ARM_MAX_VQ > 16); + /* * These are cpu model features we want to advertise. The order here * matters as this is the order in which qmp_query_cpu_model_expansion @@ -98,6 +100,9 @@ GICCapabilityList *qmp_query_gic_capabilities(Error **errp) */ static const char *cpu_model_advertised_features[] = { "aarch64", "pmu", "sve", + "sve128", "sve256", "sve384", "sve512", + "sve640", "sve768", "sve896", "sve1024", "sve1152", "sve1280", + "sve1408", "sve1536", "sve1664", "sve1792", "sve1920", "sve2048", NULL }; @@ -186,6 +191,9 @@ CpuModelExpansionInfo *qmp_query_cpu_model_expansion(CpuModelExpansionType type, if (!err) { visit_check_struct(visitor, &err); } + if (!err) { + arm_cpu_finalize_features(ARM_CPU(obj), &err); + } visit_end_struct(visitor, NULL); visit_free(visitor); if (err) { @@ -193,6 +201,10 @@ CpuModelExpansionInfo *qmp_query_cpu_model_expansion(CpuModelExpansionType type, error_propagate(errp, err); return NULL; } + } else { + Error *err = NULL; + arm_cpu_finalize_features(ARM_CPU(obj), &err); + assert(err == NULL); } expansion_info = g_new0(CpuModelExpansionInfo, 1); diff --git a/tests/arm-cpu-features.c b/tests/arm-cpu-features.c index 6342cd2e4ec..5eecd38f6c6 100644 --- a/tests/arm-cpu-features.c +++ b/tests/arm-cpu-features.c @@ -9,10 +9,17 @@ * See the COPYING file in the top-level directory. */ #include "qemu/osdep.h" +#include "qemu/bitops.h" #include "libqtest.h" #include "qapi/qmp/qdict.h" #include "qapi/qmp/qjson.h" +/* + * We expect the SVE max-vq to be 16. Also it must be <= 64 + * for our test code, otherwise 'vls' can't just be a uint64_t. + */ +#define SVE_MAX_VQ 16 + #define MACHINE "-machine virt,gic-version=max " #define QUERY_HEAD "{ 'execute': 'query-cpu-model-expansion', " \ "'arguments': { 'type': 'full', " @@ -157,6 +164,183 @@ static void assert_bad_props(QTestState *qts, const char *cpu_type) qobject_unref(resp); } +static uint64_t resp_get_sve_vls(QDict *resp) +{ + QDict *props; + const QDictEntry *e; + uint64_t vls = 0; + int n = 0; + + g_assert(resp); + g_assert(resp_has_props(resp)); + + props = resp_get_props(resp); + + for (e = qdict_first(props); e; e = qdict_next(props, e)) { + if (strlen(e->key) > 3 && !strncmp(e->key, "sve", 3) && + g_ascii_isdigit(e->key[3])) { + char *endptr; + int bits; + + bits = g_ascii_strtoll(&e->key[3], &endptr, 10); + if (!bits || *endptr != '\0') { + continue; + } + + if (qdict_get_bool(props, e->key)) { + vls |= BIT_ULL((bits / 128) - 1); + } + ++n; + } + } + + g_assert(n == SVE_MAX_VQ); + + return vls; +} + +#define assert_sve_vls(qts, cpu_type, expected_vls, fmt, ...) \ +({ \ + QDict *_resp = do_query(qts, cpu_type, fmt, ##__VA_ARGS__); \ + g_assert(_resp); \ + g_assert(resp_has_props(_resp)); \ + g_assert(resp_get_sve_vls(_resp) == expected_vls); \ + qobject_unref(_resp); \ +}) + +static void sve_tests_default(QTestState *qts, const char *cpu_type) +{ + /* + * With no sve-max-vq or sve properties on the command line + * the default is to have all vector lengths enabled. This also + * tests that 'sve' is 'on' by default. + */ + assert_sve_vls(qts, cpu_type, BIT_ULL(SVE_MAX_VQ) - 1, NULL); + + /* With SVE off, all vector lengths should also be off. */ + assert_sve_vls(qts, cpu_type, 0, "{ 'sve': false }"); + + /* With SVE on, we must have at least one vector length enabled. */ + assert_error(qts, cpu_type, "cannot disable sve128", "{ 'sve128': false }"); + + /* Basic enable/disable tests. */ + assert_sve_vls(qts, cpu_type, 0x7, "{ 'sve384': true }"); + assert_sve_vls(qts, cpu_type, ((BIT_ULL(SVE_MAX_VQ) - 1) & ~BIT_ULL(2)), + "{ 'sve384': false }"); + + /* + * --------------------------------------------------------------------- + * power-of-two(vq) all-power- can can + * of-two(< vq) enable disable + * --------------------------------------------------------------------- + * vq < max_vq no MUST* yes yes + * vq < max_vq yes MUST* yes no + * --------------------------------------------------------------------- + * vq == max_vq n/a MUST* yes** yes** + * --------------------------------------------------------------------- + * vq > max_vq n/a no no yes + * vq > max_vq n/a yes yes yes + * --------------------------------------------------------------------- + * + * [*] "MUST" means this requirement must already be satisfied, + * otherwise 'max_vq' couldn't itself be enabled. + * + * [**] Not testable with the QMP interface, only with the command line. + */ + + /* max_vq := 8 */ + assert_sve_vls(qts, cpu_type, 0x8b, "{ 'sve1024': true }"); + + /* max_vq := 8, vq < max_vq, !power-of-two(vq) */ + assert_sve_vls(qts, cpu_type, 0x8f, + "{ 'sve1024': true, 'sve384': true }"); + assert_sve_vls(qts, cpu_type, 0x8b, + "{ 'sve1024': true, 'sve384': false }"); + + /* max_vq := 8, vq < max_vq, power-of-two(vq) */ + assert_sve_vls(qts, cpu_type, 0x8b, + "{ 'sve1024': true, 'sve256': true }"); + assert_error(qts, cpu_type, "cannot disable sve256", + "{ 'sve1024': true, 'sve256': false }"); + + /* max_vq := 3, vq > max_vq, !all-power-of-two(< vq) */ + assert_error(qts, cpu_type, "cannot disable sve512", + "{ 'sve384': true, 'sve512': false, 'sve640': true }"); + + /* + * We can disable power-of-two vector lengths when all larger lengths + * are also disabled. We only need to disable the power-of-two length, + * as all non-enabled larger lengths will then be auto-disabled. + */ + assert_sve_vls(qts, cpu_type, 0x7, "{ 'sve512': false }"); + + /* max_vq := 3, vq > max_vq, all-power-of-two(< vq) */ + assert_sve_vls(qts, cpu_type, 0x1f, + "{ 'sve384': true, 'sve512': true, 'sve640': true }"); + assert_sve_vls(qts, cpu_type, 0xf, + "{ 'sve384': true, 'sve512': true, 'sve640': false }"); +} + +static void sve_tests_sve_max_vq_8(const void *data) +{ + QTestState *qts; + + qts = qtest_init(MACHINE "-cpu max,sve-max-vq=8"); + + assert_sve_vls(qts, "max", BIT_ULL(8) - 1, NULL); + + /* + * Disabling the max-vq set by sve-max-vq is not allowed, but + * of course enabling it is OK. + */ + assert_error(qts, "max", "cannot disable sve1024", "{ 'sve1024': false }"); + assert_sve_vls(qts, "max", 0xff, "{ 'sve1024': true }"); + + /* + * Enabling anything larger than max-vq set by sve-max-vq is not + * allowed, but of course disabling everything larger is OK. + */ + assert_error(qts, "max", "cannot enable sve1152", "{ 'sve1152': true }"); + assert_sve_vls(qts, "max", 0xff, "{ 'sve1152': false }"); + + /* + * We can enable/disable non power-of-two lengths smaller than the + * max-vq set by sve-max-vq, but, while we can enable power-of-two + * lengths, we can't disable them. + */ + assert_sve_vls(qts, "max", 0xff, "{ 'sve384': true }"); + assert_sve_vls(qts, "max", 0xfb, "{ 'sve384': false }"); + assert_sve_vls(qts, "max", 0xff, "{ 'sve256': true }"); + assert_error(qts, "max", "cannot disable sve256", "{ 'sve256': false }"); + + qtest_quit(qts); +} + +static void sve_tests_sve_off(const void *data) +{ + QTestState *qts; + + qts = qtest_init(MACHINE "-cpu max,sve=off"); + + /* SVE is off, so the map should be empty. */ + assert_sve_vls(qts, "max", 0, NULL); + + /* The map stays empty even if we turn lengths off. */ + assert_sve_vls(qts, "max", 0, "{ 'sve128': false }"); + + /* It's an error to enable lengths when SVE is off. */ + assert_error(qts, "max", "cannot enable sve128", "{ 'sve128': true }"); + + /* With SVE re-enabled we should get all vector lengths enabled. */ + assert_sve_vls(qts, "max", BIT_ULL(SVE_MAX_VQ) - 1, "{ 'sve': true }"); + + /* Or enable SVE with just specific vector lengths. */ + assert_sve_vls(qts, "max", 0x3, + "{ 'sve': true, 'sve128': true, 'sve256': true }"); + + qtest_quit(qts); +} + static void test_query_cpu_model_expansion(const void *data) { QTestState *qts; @@ -180,9 +364,12 @@ static void test_query_cpu_model_expansion(const void *data) if (g_str_equal(qtest_get_arch(), "aarch64")) { assert_has_feature(qts, "max", "aarch64"); assert_has_feature(qts, "max", "sve"); + assert_has_feature(qts, "max", "sve128"); assert_has_feature(qts, "cortex-a57", "pmu"); assert_has_feature(qts, "cortex-a57", "aarch64"); + sve_tests_default(qts, "max"); + /* Test that features that depend on KVM generate errors without. */ assert_error(qts, "max", "'aarch64' feature cannot be disabled " @@ -232,6 +419,13 @@ int main(int argc, char **argv) qtest_add_data_func("/arm/query-cpu-model-expansion", NULL, test_query_cpu_model_expansion); + if (g_str_equal(qtest_get_arch(), "aarch64")) { + qtest_add_data_func("/arm/max/query-cpu-model-expansion/sve-max-vq-8", + NULL, sve_tests_sve_max_vq_8); + qtest_add_data_func("/arm/max/query-cpu-model-expansion/sve-off", + NULL, sve_tests_sve_off); + } + if (kvm_available) { qtest_add_data_func("/arm/kvm/query-cpu-model-expansion", NULL, test_query_cpu_model_expansion_kvm); diff --git a/docs/arm-cpu-features.rst b/docs/arm-cpu-features.rst index c79dcffb555..2ea4d6e90c0 100644 --- a/docs/arm-cpu-features.rst +++ b/docs/arm-cpu-features.rst @@ -48,18 +48,31 @@ block in the script for usage) is used to issue the QMP commands. (QEMU) query-cpu-model-expansion type=full model={"name":"max"} { "return": { "model": { "name": "max", "props": { - "pmu": true, "aarch64": true + "sve1664": true, "pmu": true, "sve1792": true, "sve1920": true, + "sve128": true, "aarch64": true, "sve1024": true, "sve": true, + "sve640": true, "sve768": true, "sve1408": true, "sve256": true, + "sve1152": true, "sve512": true, "sve384": true, "sve1536": true, + "sve896": true, "sve1280": true, "sve2048": true }}}} -We see that the `max` CPU type has the `pmu` and `aarch64` CPU features. -We also see that the CPU features are enabled, as they are all `true`. +We see that the `max` CPU type has the `pmu`, `aarch64`, `sve`, and many +`sve` CPU features. We also see that all the CPU features are +enabled, as they are all `true`. (The `sve` CPU features are all +optional SVE vector lengths (see "SVE CPU Properties"). While with TCG +all SVE vector lengths can be supported, when KVM is in use it's more +likely that only a few lengths will be supported, if SVE is supported at +all.) (2) Let's try to disable the PMU:: (QEMU) query-cpu-model-expansion type=full model={"name":"max","props":{"pmu":false}} { "return": { "model": { "name": "max", "props": { - "pmu": false, "aarch64": true + "sve1664": true, "pmu": false, "sve1792": true, "sve1920": true, + "sve128": true, "aarch64": true, "sve1024": true, "sve": true, + "sve640": true, "sve768": true, "sve1408": true, "sve256": true, + "sve1152": true, "sve512": true, "sve384": true, "sve1536": true, + "sve896": true, "sve1280": true, "sve2048": true }}}} We see it worked, as `pmu` is now `false`. @@ -75,7 +88,22 @@ We see it worked, as `pmu` is now `false`. It looks like this feature is limited to a configuration we do not currently have. -(4) Let's try probing CPU features for the Cortex-A15 CPU type:: +(4) Let's disable `sve` and see what happens to all the optional SVE + vector lengths:: + + (QEMU) query-cpu-model-expansion type=full model={"name":"max","props":{"sve":false}} + { "return": { + "model": { "name": "max", "props": { + "sve1664": false, "pmu": true, "sve1792": false, "sve1920": false, + "sve128": false, "aarch64": true, "sve1024": false, "sve": false, + "sve640": false, "sve768": false, "sve1408": false, "sve256": false, + "sve1152": false, "sve512": false, "sve384": false, "sve1536": false, + "sve896": false, "sve1280": false, "sve2048": false + }}}} + +As expected they are now all `false`. + +(5) Let's try probing CPU features for the Cortex-A15 CPU type:: (QEMU) query-cpu-model-expansion type=full model={"name":"cortex-a15"} {"return": {"model": {"name": "cortex-a15", "props": {"pmu": true}}}} @@ -131,7 +159,133 @@ After determining which CPU features are available and supported for a given CPU type, then they may be selectively enabled or disabled on the QEMU command line with that CPU type:: - $ qemu-system-aarch64 -M virt -cpu max,pmu=off + $ qemu-system-aarch64 -M virt -cpu max,pmu=off,sve=on,sve128=on,sve256=on -The example above disables the PMU for the `max` CPU type. +The example above disables the PMU and enables the first two SVE vector +lengths for the `max` CPU type. Note, the `sve=on` isn't actually +necessary, because, as we observed above with our probe of the `max` CPU +type, `sve` is already on by default. Also, based on our probe of +defaults, it would seem we need to disable many SVE vector lengths, rather +than only enabling the two we want. This isn't the case, because, as +disabling many SVE vector lengths would be quite verbose, the `sve` CPU +properties have special semantics (see "SVE CPU Property Parsing +Semantics"). + +SVE CPU Properties +================== + +There are two types of SVE CPU properties: `sve` and `sve`. The first +is used to enable or disable the entire SVE feature, just as the `pmu` +CPU property completely enables or disables the PMU. The second type +is used to enable or disable specific vector lengths, where `N` is the +number of bits of the length. The `sve` CPU properties have special +dependencies and constraints, see "SVE CPU Property Dependencies and +Constraints" below. Additionally, as we want all supported vector lengths +to be enabled by default, then, in order to avoid overly verbose command +lines (command lines full of `sve=off`, for all `N` not wanted), we +provide the parsing semantics listed in "SVE CPU Property Parsing +Semantics". + +SVE CPU Property Dependencies and Constraints +--------------------------------------------- + + 1) At least one vector length must be enabled when `sve` is enabled. + + 2) If a vector length `N` is enabled, then all power-of-two vector + lengths smaller than `N` must also be enabled. E.g. if `sve512` + is enabled, then the 128-bit and 256-bit vector lengths must also + be enabled. + +SVE CPU Property Parsing Semantics +---------------------------------- + + 1) If SVE is disabled (`sve=off`), then which SVE vector lengths + are enabled or disabled is irrelevant to the guest, as the entire + SVE feature is disabled and that disables all vector lengths for + the guest. However QEMU will still track any `sve` CPU + properties provided by the user. If later an `sve=on` is provided, + then the guest will get only the enabled lengths. If no `sve=on` + is provided and there are explicitly enabled vector lengths, then + an error is generated. + + 2) If SVE is enabled (`sve=on`), but no `sve` CPU properties are + provided, then all supported vector lengths are enabled, including + the non-power-of-two lengths. + + 3) If SVE is enabled, then an error is generated when attempting to + disable the last enabled vector length (see constraint (1) of "SVE + CPU Property Dependencies and Constraints"). + + 4) If one or more vector lengths have been explicitly enabled and at + at least one of the dependency lengths of the maximum enabled length + has been explicitly disabled, then an error is generated (see + constraint (2) of "SVE CPU Property Dependencies and Constraints"). + + 5) If one or more `sve` CPU properties are set `off`, but no `sve`, + CPU properties are set `on`, then the specified vector lengths are + disabled but the default for any unspecified lengths remains enabled. + Disabling a power-of-two vector length also disables all vector + lengths larger than the power-of-two length (see constraint (2) of + "SVE CPU Property Dependencies and Constraints"). + + 6) If one or more `sve` CPU properties are set to `on`, then they + are enabled and all unspecified lengths default to disabled, except + for the required lengths per constraint (2) of "SVE CPU Property + Dependencies and Constraints", which will even be auto-enabled if + they were not explicitly enabled. + + 7) If SVE was disabled (`sve=off`), allowing all vector lengths to be + explicitly disabled (i.e. avoiding the error specified in (3) of + "SVE CPU Property Parsing Semantics"), then if later an `sve=on` is + provided an error will be generated. To avoid this error, one must + enable at least one vector length prior to enabling SVE. + +SVE CPU Property Examples +------------------------- + + 1) Disable SVE:: + + $ qemu-system-aarch64 -M virt -cpu max,sve=off + + 2) Implicitly enable all vector lengths for the `max` CPU type:: + + $ qemu-system-aarch64 -M virt -cpu max + + 3) Only enable the 128-bit vector length:: + + $ qemu-system-aarch64 -M virt -cpu max,sve128=on + + 4) Disable the 512-bit vector length and all larger vector lengths, + since 512 is a power-of-two. This results in all the smaller, + uninitialized lengths (128, 256, and 384) defaulting to enabled:: + + $ qemu-system-aarch64 -M virt -cpu max,sve512=off + + 5) Enable the 128-bit, 256-bit, and 512-bit vector lengths:: + + $ qemu-system-aarch64 -M virt -cpu max,sve128=on,sve256=on,sve512=on + + 6) The same as (5), but since the 128-bit and 256-bit vector + lengths are required for the 512-bit vector length to be enabled, + then allow them to be auto-enabled:: + + $ qemu-system-aarch64 -M virt -cpu max,sve512=on + + 7) Do the same as (6), but by first disabling SVE and then re-enabling it:: + + $ qemu-system-aarch64 -M virt -cpu max,sve=off,sve512=on,sve=on + + 8) Force errors regarding the last vector length:: + + $ qemu-system-aarch64 -M virt -cpu max,sve128=off + $ qemu-system-aarch64 -M virt -cpu max,sve=off,sve128=off,sve=on + +SVE CPU Property Recommendations +-------------------------------- + +The examples in "SVE CPU Property Examples" exhibit many ways to select +vector lengths which developers may find useful in order to avoid overly +verbose command lines. However, the recommended way to select vector +lengths is to explicitly enable each desired length. Therefore only +example's (1), (3), and (5) exhibit recommended uses of the properties. From patchwork Thu Oct 24 16:27:12 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 11210411 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 92B91112C for ; Thu, 24 Oct 2019 17:12:31 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 684A520650 for ; Thu, 24 Oct 2019 17:12:31 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="urvci2Ek" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 684A520650 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:48412 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNgf0-000676-27 for patchwork-qemu-devel@patchwork.kernel.org; Thu, 24 Oct 2019 13:12:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58240) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNfyH-0008GL-U6 for qemu-devel@nongnu.org; Thu, 24 Oct 2019 12:28:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iNfyE-00011r-CZ for qemu-devel@nongnu.org; Thu, 24 Oct 2019 12:28:21 -0400 Received: from mail-wm1-x32d.google.com ([2a00:1450:4864:20::32d]:35538) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iNfyE-00011K-5a for qemu-devel@nongnu.org; Thu, 24 Oct 2019 12:28:18 -0400 Received: by mail-wm1-x32d.google.com with SMTP id v6so3232377wmj.0 for ; Thu, 24 Oct 2019 09:28:17 -0700 (PDT) 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=hCsDjq3BTh1CFQ3xfAyc1h9/b/i1zEMVd9NMkBRbhe0=; b=urvci2Ek75Us14Ux8a0Fel60EcvAW/I50Da19obMkQH+Zyq+SjsIR0gIvOW4h7Voot veCLi53Dv/eKHn9z9tYExVcTF/eorhHeAsYNlZgjYpmATnA9CMIylrFooeAiiXzPfaa4 h4ridaGV6W6dTBac1tm+xVVx19K2AKi0iHlsrRKGWj7viQU/fWAegP9QPtYWT6draRDQ qV3Ppqvm9fu64vJ2q2ZVDst7NCLE+8We8Ld9D3tQHwF1c+Lab/Gq6ZWjWiKRszstjeHA Jry9ObaaXOa+CwWV36deWFLxteFYKb7ZoodGJmAjdwZ1KpQV5ZH5UU/BemdE5irOrnFS 2ADQ== 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=hCsDjq3BTh1CFQ3xfAyc1h9/b/i1zEMVd9NMkBRbhe0=; b=fO8aIFKBhmzzgMAfffsUvmw7oUgEjl1UPiXHGV9fGpcncWdfNJu5DuDzlLU4D4CwAx 7cohtLWF8GMFg0GVA7AZCAMidCCPSFrn93QYX8a62Y6o73LMj4D8akljYCPwR1MQ5cF+ e5QBvow+lK7cy/17o4UXquUlt6yvs92r6fT2YBa+NNUt7sAd/eSoIy3W2NnWqSshhpju ymEyahuvKAYlQoY4zeFGa0eGVrghCjxlj0H64F2hKyma9J75icfHQGGq4k0tKGxbBC4n tckb1hS6H6qMmDk45+0XarnZiQ3cwTP1Rq8u1sNcHWblfC0jQlDrhrdkNQWq0lVklkj5 mnGQ== X-Gm-Message-State: APjAAAV9AqeH46QggRFOfrQyJmLhMwtMpKTPqHtg+4vKbLWOnq21VxJm A7oEzSnhWwc0Xw5mBi87TqyzBVdYvTE= X-Google-Smtp-Source: APXvYqxr6P3RJgLYPjEzexq3KGYytDLGSs/zDf/emXawPeFwJa9NIW6+0mTFJgHdD8scnH3iJRUS1A== X-Received: by 2002:a1c:9d07:: with SMTP id g7mr5740556wme.53.1571934495721; Thu, 24 Oct 2019 09:28:15 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id r27sm42606124wrc.55.2019.10.24.09.28.14 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Oct 2019 09:28:15 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 39/51] target/arm/kvm64: Add kvm_arch_get/put_sve Date: Thu, 24 Oct 2019 17:27:12 +0100 Message-Id: <20191024162724.31675-40-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191024162724.31675-1-peter.maydell@linaro.org> References: <20191024162724.31675-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::32d X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" From: Andrew Jones These are the SVE equivalents to kvm_arch_get/put_fpsimd. Note, the swabbing is different than it is for fpsmid because the vector format is a little-endian stream of words. Signed-off-by: Andrew Jones Reviewed-by: Richard Henderson Reviewed-by: Eric Auger Tested-by: Masayoshi Mizuma Message-id: 20191024121808.9612-6-drjones@redhat.com Signed-off-by: Peter Maydell --- target/arm/kvm64.c | 185 ++++++++++++++++++++++++++++++++++++++------- 1 file changed, 156 insertions(+), 29 deletions(-) diff --git a/target/arm/kvm64.c b/target/arm/kvm64.c index 28f6db57d5e..4c0b11d105a 100644 --- a/target/arm/kvm64.c +++ b/target/arm/kvm64.c @@ -671,11 +671,12 @@ int kvm_arch_destroy_vcpu(CPUState *cs) bool kvm_arm_reg_syncs_via_cpreg_list(uint64_t regidx) { /* Return true if the regidx is a register we should synchronize - * via the cpreg_tuples array (ie is not a core reg we sync by - * hand in kvm_arch_get/put_registers()) + * via the cpreg_tuples array (ie is not a core or sve reg that + * we sync by hand in kvm_arch_get/put_registers()) */ switch (regidx & KVM_REG_ARM_COPROC_MASK) { case KVM_REG_ARM_CORE: + case KVM_REG_ARM64_SVE: return false; default: return true; @@ -721,10 +722,8 @@ int kvm_arm_cpreg_level(uint64_t regidx) static int kvm_arch_put_fpsimd(CPUState *cs) { - ARMCPU *cpu = ARM_CPU(cs); - CPUARMState *env = &cpu->env; + CPUARMState *env = &ARM_CPU(cs)->env; struct kvm_one_reg reg; - uint32_t fpr; int i, ret; for (i = 0; i < 32; i++) { @@ -742,17 +741,73 @@ static int kvm_arch_put_fpsimd(CPUState *cs) } } - reg.addr = (uintptr_t)(&fpr); - fpr = vfp_get_fpsr(env); - reg.id = AARCH64_SIMD_CTRL_REG(fp_regs.fpsr); - ret = kvm_vcpu_ioctl(cs, KVM_SET_ONE_REG, ®); - if (ret) { - return ret; + return 0; +} + +/* + * SVE registers are encoded in KVM's memory in an endianness-invariant format. + * The byte at offset i from the start of the in-memory representation contains + * the bits [(7 + 8 * i) : (8 * i)] of the register value. As this means the + * lowest offsets are stored in the lowest memory addresses, then that nearly + * matches QEMU's representation, which is to use an array of host-endian + * uint64_t's, where the lower offsets are at the lower indices. To complete + * the translation we just need to byte swap the uint64_t's on big-endian hosts. + */ +static uint64_t *sve_bswap64(uint64_t *dst, uint64_t *src, int nr) +{ +#ifdef HOST_WORDS_BIGENDIAN + int i; + + for (i = 0; i < nr; ++i) { + dst[i] = bswap64(src[i]); } - reg.addr = (uintptr_t)(&fpr); - fpr = vfp_get_fpcr(env); - reg.id = AARCH64_SIMD_CTRL_REG(fp_regs.fpcr); + return dst; +#else + return src; +#endif +} + +/* + * KVM SVE registers come in slices where ZREGs have a slice size of 2048 bits + * and PREGS and the FFR have a slice size of 256 bits. However we simply hard + * code the slice index to zero for now as it's unlikely we'll need more than + * one slice for quite some time. + */ +static int kvm_arch_put_sve(CPUState *cs) +{ + ARMCPU *cpu = ARM_CPU(cs); + CPUARMState *env = &cpu->env; + uint64_t tmp[ARM_MAX_VQ * 2]; + uint64_t *r; + struct kvm_one_reg reg; + int n, ret; + + for (n = 0; n < KVM_ARM64_SVE_NUM_ZREGS; ++n) { + r = sve_bswap64(tmp, &env->vfp.zregs[n].d[0], cpu->sve_max_vq * 2); + reg.addr = (uintptr_t)r; + reg.id = KVM_REG_ARM64_SVE_ZREG(n, 0); + ret = kvm_vcpu_ioctl(cs, KVM_SET_ONE_REG, ®); + if (ret) { + return ret; + } + } + + for (n = 0; n < KVM_ARM64_SVE_NUM_PREGS; ++n) { + r = sve_bswap64(tmp, r = &env->vfp.pregs[n].p[0], + DIV_ROUND_UP(cpu->sve_max_vq * 2, 8)); + reg.addr = (uintptr_t)r; + reg.id = KVM_REG_ARM64_SVE_PREG(n, 0); + ret = kvm_vcpu_ioctl(cs, KVM_SET_ONE_REG, ®); + if (ret) { + return ret; + } + } + + r = sve_bswap64(tmp, &env->vfp.pregs[FFR_PRED_NUM].p[0], + DIV_ROUND_UP(cpu->sve_max_vq * 2, 8)); + reg.addr = (uintptr_t)r; + reg.id = KVM_REG_ARM64_SVE_FFR(0); ret = kvm_vcpu_ioctl(cs, KVM_SET_ONE_REG, ®); if (ret) { return ret; @@ -765,6 +820,7 @@ int kvm_arch_put_registers(CPUState *cs, int level) { struct kvm_one_reg reg; uint64_t val; + uint32_t fpr; int i, ret; unsigned int el; @@ -855,7 +911,27 @@ int kvm_arch_put_registers(CPUState *cs, int level) } } - ret = kvm_arch_put_fpsimd(cs); + if (cpu_isar_feature(aa64_sve, cpu)) { + ret = kvm_arch_put_sve(cs); + } else { + ret = kvm_arch_put_fpsimd(cs); + } + if (ret) { + return ret; + } + + reg.addr = (uintptr_t)(&fpr); + fpr = vfp_get_fpsr(env); + reg.id = AARCH64_SIMD_CTRL_REG(fp_regs.fpsr); + ret = kvm_vcpu_ioctl(cs, KVM_SET_ONE_REG, ®); + if (ret) { + return ret; + } + + reg.addr = (uintptr_t)(&fpr); + fpr = vfp_get_fpcr(env); + reg.id = AARCH64_SIMD_CTRL_REG(fp_regs.fpcr); + ret = kvm_vcpu_ioctl(cs, KVM_SET_ONE_REG, ®); if (ret) { return ret; } @@ -878,10 +954,8 @@ int kvm_arch_put_registers(CPUState *cs, int level) static int kvm_arch_get_fpsimd(CPUState *cs) { - ARMCPU *cpu = ARM_CPU(cs); - CPUARMState *env = &cpu->env; + CPUARMState *env = &ARM_CPU(cs)->env; struct kvm_one_reg reg; - uint32_t fpr; int i, ret; for (i = 0; i < 32; i++) { @@ -899,21 +973,53 @@ static int kvm_arch_get_fpsimd(CPUState *cs) } } - reg.addr = (uintptr_t)(&fpr); - reg.id = AARCH64_SIMD_CTRL_REG(fp_regs.fpsr); - ret = kvm_vcpu_ioctl(cs, KVM_GET_ONE_REG, ®); - if (ret) { - return ret; - } - vfp_set_fpsr(env, fpr); + return 0; +} - reg.addr = (uintptr_t)(&fpr); - reg.id = AARCH64_SIMD_CTRL_REG(fp_regs.fpcr); +/* + * KVM SVE registers come in slices where ZREGs have a slice size of 2048 bits + * and PREGS and the FFR have a slice size of 256 bits. However we simply hard + * code the slice index to zero for now as it's unlikely we'll need more than + * one slice for quite some time. + */ +static int kvm_arch_get_sve(CPUState *cs) +{ + ARMCPU *cpu = ARM_CPU(cs); + CPUARMState *env = &cpu->env; + struct kvm_one_reg reg; + uint64_t *r; + int n, ret; + + for (n = 0; n < KVM_ARM64_SVE_NUM_ZREGS; ++n) { + r = &env->vfp.zregs[n].d[0]; + reg.addr = (uintptr_t)r; + reg.id = KVM_REG_ARM64_SVE_ZREG(n, 0); + ret = kvm_vcpu_ioctl(cs, KVM_GET_ONE_REG, ®); + if (ret) { + return ret; + } + sve_bswap64(r, r, cpu->sve_max_vq * 2); + } + + for (n = 0; n < KVM_ARM64_SVE_NUM_PREGS; ++n) { + r = &env->vfp.pregs[n].p[0]; + reg.addr = (uintptr_t)r; + reg.id = KVM_REG_ARM64_SVE_PREG(n, 0); + ret = kvm_vcpu_ioctl(cs, KVM_GET_ONE_REG, ®); + if (ret) { + return ret; + } + sve_bswap64(r, r, DIV_ROUND_UP(cpu->sve_max_vq * 2, 8)); + } + + r = &env->vfp.pregs[FFR_PRED_NUM].p[0]; + reg.addr = (uintptr_t)r; + reg.id = KVM_REG_ARM64_SVE_FFR(0); ret = kvm_vcpu_ioctl(cs, KVM_GET_ONE_REG, ®); if (ret) { return ret; } - vfp_set_fpcr(env, fpr); + sve_bswap64(r, r, DIV_ROUND_UP(cpu->sve_max_vq * 2, 8)); return 0; } @@ -923,6 +1029,7 @@ int kvm_arch_get_registers(CPUState *cs) struct kvm_one_reg reg; uint64_t val; unsigned int el; + uint32_t fpr; int i, ret; ARMCPU *cpu = ARM_CPU(cs); @@ -1012,11 +1119,31 @@ int kvm_arch_get_registers(CPUState *cs) env->spsr = env->banked_spsr[i]; } - ret = kvm_arch_get_fpsimd(cs); + if (cpu_isar_feature(aa64_sve, cpu)) { + ret = kvm_arch_get_sve(cs); + } else { + ret = kvm_arch_get_fpsimd(cs); + } if (ret) { return ret; } + reg.addr = (uintptr_t)(&fpr); + reg.id = AARCH64_SIMD_CTRL_REG(fp_regs.fpsr); + ret = kvm_vcpu_ioctl(cs, KVM_GET_ONE_REG, ®); + if (ret) { + return ret; + } + vfp_set_fpsr(env, fpr); + + reg.addr = (uintptr_t)(&fpr); + reg.id = AARCH64_SIMD_CTRL_REG(fp_regs.fpcr); + ret = kvm_vcpu_ioctl(cs, KVM_GET_ONE_REG, ®); + if (ret) { + return ret; + } + vfp_set_fpcr(env, fpr); + ret = kvm_get_vcpu_events(cpu); if (ret) { return ret; From patchwork Thu Oct 24 16:27:13 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 11210485 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3EBBB1575 for ; Thu, 24 Oct 2019 17:18:05 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 1509620659 for ; Thu, 24 Oct 2019 17:18:05 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="waRai1xv" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1509620659 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:48526 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNgkN-0001pt-Kq for patchwork-qemu-devel@patchwork.kernel.org; Thu, 24 Oct 2019 13:18:03 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58225) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNfyG-0008Dx-9Y for qemu-devel@nongnu.org; Thu, 24 Oct 2019 12:28:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iNfyE-000127-LY for qemu-devel@nongnu.org; Thu, 24 Oct 2019 12:28:20 -0400 Received: from mail-wr1-x436.google.com ([2a00:1450:4864:20::436]:43211) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iNfyE-00011U-Eg for qemu-devel@nongnu.org; Thu, 24 Oct 2019 12:28:18 -0400 Received: by mail-wr1-x436.google.com with SMTP id c2so21571513wrr.10 for ; Thu, 24 Oct 2019 09:28:18 -0700 (PDT) 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=I1XdSXHXRiwCyyQ8+g7Xy9Yc2JAcqF8GhBJsyFcDdek=; b=waRai1xvmeMbPcPapy10lpx/y0+piA7e/R8TqvJq0jHTMGHtUdBh6VN93yXp8x+8Pp Wxp1kWXXYwmo9lBYG2Pk+kDV2zxgVoba4v7O5mvCZ9oGUT0bYqrrTOgKZHttKVuoV+78 0Mrwic3HXwXa9Vq2JavkPykeC9sjTuCEfC9yrT9DFn//7JqpLBiVsPTPwtwu5/rgxwVm o+PUnJLgnmEjotaulpZJiz1eXJvISeskkj4dtMT5ET+LAomZpEvixpbovhvdJ2HL86Dh QBMViVZlxxKtywdtiQhwy+83o9vCIxywuhWNWJ9z6G++Sn2FMTbvJjRy2oPxq2UIVylB hmIQ== 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=I1XdSXHXRiwCyyQ8+g7Xy9Yc2JAcqF8GhBJsyFcDdek=; b=oKAg2/ZA9ktCnUpX5UgbURsqGopIX0emjX+KVL0lFgnU4I5mTh/7qi4RDlI4KbBAS1 t12VJOoZHd1UaCcqlpn4ARyWMy6c1gPHvNuWQEbpPgAbQtGrQYCaFLvbSvpB9byhAtWt vEKOoYBe8+WLd/a4tGsSjf658t+WQAKShTkxBTw62ZkZTwP1UcXX/udmbM5G/QiaSsaZ g16RNPH5uMeGEaeDxV6+9O7LjFDoSLLtw5Xlshro35H5WtOSc9AoQia0Ec/dp95/mcqQ aktoPhVkvQlrmIgWYnGfG0+3U0xRFzsxk9XVGoz8OTWfN7op80wjUGe5r+ovCvVYDqta /Qbg== X-Gm-Message-State: APjAAAWTiqplwOb9hXzAJZbcXUms5oTd5HLDPi0QpnD7uVgxTgy9FafW Rtl/T545aEzHpAla3wX+uw3VMhztFb4= X-Google-Smtp-Source: APXvYqwLranh7mWEotZPpNzLMb66hpc70e4mbFkBhVMjMtngFURSD8gCm+xF7BO6rJGxgLirOWJ6iw== X-Received: by 2002:a5d:6402:: with SMTP id z2mr4731751wru.211.1571934497045; Thu, 24 Oct 2019 09:28:17 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id r27sm42606124wrc.55.2019.10.24.09.28.15 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Oct 2019 09:28:16 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 40/51] target/arm/kvm64: max cpu: Enable SVE when available Date: Thu, 24 Oct 2019 17:27:13 +0100 Message-Id: <20191024162724.31675-41-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191024162724.31675-1-peter.maydell@linaro.org> References: <20191024162724.31675-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 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" From: Andrew Jones Enable SVE in the KVM guest when the 'max' cpu type is configured and KVM supports it. KVM SVE requires use of the new finalize vcpu ioctl, so we add that now too. For starters SVE can only be turned on or off, getting all vector lengths the host CPU supports when on. We'll add the other SVE CPU properties in later patches. Signed-off-by: Andrew Jones Reviewed-by: Richard Henderson Reviewed-by: Eric Auger Tested-by: Masayoshi Mizuma Reviewed-by: Beata Michalska Message-id: 20191024121808.9612-7-drjones@redhat.com Signed-off-by: Peter Maydell --- target/arm/kvm_arm.h | 27 +++++++++++++++++++++++++++ target/arm/cpu64.c | 17 ++++++++++++++--- target/arm/kvm.c | 5 +++++ target/arm/kvm64.c | 20 +++++++++++++++++++- tests/arm-cpu-features.c | 4 ++++ 5 files changed, 69 insertions(+), 4 deletions(-) diff --git a/target/arm/kvm_arm.h b/target/arm/kvm_arm.h index b4e19457a09..7c12f1501a8 100644 --- a/target/arm/kvm_arm.h +++ b/target/arm/kvm_arm.h @@ -27,6 +27,20 @@ */ int kvm_arm_vcpu_init(CPUState *cs); +/** + * kvm_arm_vcpu_finalize + * @cs: CPUState + * @feature: int + * + * Finalizes the configuration of the specified VCPU feature by + * invoking the KVM_ARM_VCPU_FINALIZE ioctl. Features requiring + * this are documented in the "KVM_ARM_VCPU_FINALIZE" section of + * KVM's API documentation. + * + * Returns: 0 if success else < 0 error code + */ +int kvm_arm_vcpu_finalize(CPUState *cs, int feature); + /** * kvm_arm_register_device: * @mr: memory region for this device @@ -225,6 +239,14 @@ bool kvm_arm_aarch32_supported(CPUState *cs); */ bool kvm_arm_pmu_supported(CPUState *cs); +/** + * bool kvm_arm_sve_supported: + * @cs: CPUState + * + * Returns true if the KVM VCPU can enable SVE and false otherwise. + */ +bool kvm_arm_sve_supported(CPUState *cs); + /** * kvm_arm_get_max_vm_ipa_size - Returns the number of bits in the * IPA address space supported by KVM @@ -276,6 +298,11 @@ static inline bool kvm_arm_pmu_supported(CPUState *cs) return false; } +static inline bool kvm_arm_sve_supported(CPUState *cs) +{ + return false; +} + static inline int kvm_arm_get_max_vm_ipa_size(MachineState *ms) { return -ENOENT; diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c index 34b0ba2cf6f..a771a28daa5 100644 --- a/target/arm/cpu64.c +++ b/target/arm/cpu64.c @@ -493,6 +493,11 @@ static void cpu_arm_set_sve(Object *obj, Visitor *v, const char *name, return; } + if (value && kvm_enabled() && !kvm_arm_sve_supported(CPU(cpu))) { + error_setg(errp, "'sve' feature not supported by KVM on this host"); + return; + } + t = cpu->isar.id_aa64pfr0; t = FIELD_DP64(t, ID_AA64PFR0, SVE, value); cpu->isar.id_aa64pfr0 = t; @@ -507,11 +512,16 @@ static void aarch64_max_initfn(Object *obj) { ARMCPU *cpu = ARM_CPU(obj); uint32_t vq; + uint64_t t; if (kvm_enabled()) { kvm_arm_set_cpu_features_from_host(cpu); + if (kvm_arm_sve_supported(CPU(cpu))) { + t = cpu->isar.id_aa64pfr0; + t = FIELD_DP64(t, ID_AA64PFR0, SVE, 1); + cpu->isar.id_aa64pfr0 = t; + } } else { - uint64_t t; uint32_t u; aarch64_a57_initfn(obj); @@ -612,8 +622,6 @@ static void aarch64_max_initfn(Object *obj) object_property_add(obj, "sve-max-vq", "uint32", cpu_max_get_sve_max_vq, cpu_max_set_sve_max_vq, NULL, NULL, &error_fatal); - object_property_add(obj, "sve", "bool", cpu_arm_get_sve, - cpu_arm_set_sve, NULL, NULL, &error_fatal); for (vq = 1; vq <= ARM_MAX_VQ; ++vq) { char name[8]; @@ -622,6 +630,9 @@ static void aarch64_max_initfn(Object *obj) cpu_arm_set_sve_vq, NULL, NULL, &error_fatal); } } + + object_property_add(obj, "sve", "bool", cpu_arm_get_sve, + cpu_arm_set_sve, NULL, NULL, &error_fatal); } struct ARMCPUInfo { diff --git a/target/arm/kvm.c b/target/arm/kvm.c index b473c63edb1..f07332bbda3 100644 --- a/target/arm/kvm.c +++ b/target/arm/kvm.c @@ -51,6 +51,11 @@ int kvm_arm_vcpu_init(CPUState *cs) return kvm_vcpu_ioctl(cs, KVM_ARM_VCPU_INIT, &init); } +int kvm_arm_vcpu_finalize(CPUState *cs, int feature) +{ + return kvm_vcpu_ioctl(cs, KVM_ARM_VCPU_FINALIZE, &feature); +} + void kvm_arm_init_serror_injection(CPUState *cs) { cap_has_inject_serror_esr = kvm_check_extension(cs->kvm_state, diff --git a/target/arm/kvm64.c b/target/arm/kvm64.c index 4c0b11d105a..850da1b5e6a 100644 --- a/target/arm/kvm64.c +++ b/target/arm/kvm64.c @@ -602,6 +602,13 @@ bool kvm_arm_aarch32_supported(CPUState *cpu) return kvm_check_extension(s, KVM_CAP_ARM_EL1_32BIT); } +bool kvm_arm_sve_supported(CPUState *cpu) +{ + KVMState *s = KVM_STATE(current_machine->accelerator); + + return kvm_check_extension(s, KVM_CAP_ARM_SVE); +} + #define ARM_CPU_ID_MPIDR 3, 0, 0, 0, 5 int kvm_arch_init_vcpu(CPUState *cs) @@ -630,13 +637,17 @@ int kvm_arch_init_vcpu(CPUState *cs) cpu->kvm_init_features[0] |= 1 << KVM_ARM_VCPU_EL1_32BIT; } if (!kvm_check_extension(cs->kvm_state, KVM_CAP_ARM_PMU_V3)) { - cpu->has_pmu = false; + cpu->has_pmu = false; } if (cpu->has_pmu) { cpu->kvm_init_features[0] |= 1 << KVM_ARM_VCPU_PMU_V3; } else { unset_feature(&env->features, ARM_FEATURE_PMU); } + if (cpu_isar_feature(aa64_sve, cpu)) { + assert(kvm_arm_sve_supported(cs)); + cpu->kvm_init_features[0] |= 1 << KVM_ARM_VCPU_SVE; + } /* Do KVM_ARM_VCPU_INIT ioctl */ ret = kvm_arm_vcpu_init(cs); @@ -644,6 +655,13 @@ int kvm_arch_init_vcpu(CPUState *cs) return ret; } + if (cpu_isar_feature(aa64_sve, cpu)) { + ret = kvm_arm_vcpu_finalize(cs, KVM_ARM_VCPU_SVE); + if (ret) { + return ret; + } + } + /* * When KVM is in use, PSCI is emulated in-kernel and not by qemu. * Currently KVM has its own idea about MPIDR assignment, so we diff --git a/tests/arm-cpu-features.c b/tests/arm-cpu-features.c index 5eecd38f6c6..3efc168d62a 100644 --- a/tests/arm-cpu-features.c +++ b/tests/arm-cpu-features.c @@ -391,12 +391,16 @@ static void test_query_cpu_model_expansion_kvm(const void *data) assert_has_feature(qts, "host", "aarch64"); assert_has_feature(qts, "host", "pmu"); + assert_has_feature(qts, "max", "sve"); + assert_error(qts, "cortex-a15", "We cannot guarantee the CPU type 'cortex-a15' works " "with KVM on this host", NULL); } else { assert_has_not_feature(qts, "host", "aarch64"); assert_has_not_feature(qts, "host", "pmu"); + + assert_has_not_feature(qts, "max", "sve"); } qtest_quit(qts); From patchwork Thu Oct 24 16:27:14 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 11210491 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id CE0C11575 for ; Thu, 24 Oct 2019 17:21:26 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A430020659 for ; Thu, 24 Oct 2019 17:21:26 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="Ron7P1Kt" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A430020659 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:48582 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNgnd-0002Cq-HH for patchwork-qemu-devel@patchwork.kernel.org; Thu, 24 Oct 2019 13:21:25 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58246) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNfyI-0008HV-Cg for qemu-devel@nongnu.org; Thu, 24 Oct 2019 12:28:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iNfyG-00012a-0G for qemu-devel@nongnu.org; Thu, 24 Oct 2019 12:28:22 -0400 Received: from mail-wr1-x42d.google.com ([2a00:1450:4864:20::42d]:44677) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iNfyF-00012K-Pz for qemu-devel@nongnu.org; Thu, 24 Oct 2019 12:28:19 -0400 Received: by mail-wr1-x42d.google.com with SMTP id z11so3426426wro.11 for ; Thu, 24 Oct 2019 09:28:19 -0700 (PDT) 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=0ZlsAUBDsUyvYREq9UC6PUhIuy2cFHkEmU/zq4fnk1M=; b=Ron7P1Kt2i5RKXFToDi+kwl7uGK+AxvNo1pO1MP/jp7ROARYQ795E1kCn1ORVCDvQY WsjTpBhdhPYejrnHX2ZYAD8o3iqPLB88xyQy34giOURqftcOCyVwDrmTgI/pEv4a1t0c o9cuK4N0qg/XTGh5eLYqoEqPg6uFO/K5z35DaWMpwVjgkSWiky6wgw8azSqGS9cAMIwa QATAqevuzY7GTF/aRuSwmWysULHGnUlUQFmvFRTFyiGrY0Veur96TOCpEoRwPoW1ANmt 0/V07LePZxDzop38LO8d/BeeBmsaYAO1agfHov5YQUhzReawF13cviMdQRfLdEx7ywpJ Fg+w== 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=0ZlsAUBDsUyvYREq9UC6PUhIuy2cFHkEmU/zq4fnk1M=; b=BRYfm/Mq9WjUzzsOi6+DaW/5QuWTy0apzk5gxKodWzZw/S1sPPgaIEzHKYfjqSU71U fHJ+T6QR4mVBqLHaktzcTHtdxAZa5B0PhaC7nTVmSoMCIPyuHn64s8+JkTeptADhwXVp 9blorl+kFdkkTVJXqZBhmw3i1ja9pJzgCagbFk2ipyLIN32xQHjjGGpp1fy7Qcdf9x5M fLo2VRHjektfjIcTv2KyZ0iBIJ0xtJwVSZS4JTtV7+ld3ohMgfIPihSVnEBQYbpx654J I5o2phtFCTBNGstoQ+Qajk1hwpNtBx2j6dy+aK/9tX/5mWFSd1dDfyWWg5NTw5zsa7xZ AtbA== X-Gm-Message-State: APjAAAV8WsLeGf+dCO52ney5VdA706uQdTKwNA7RcyKRUiPvhrKoJ1MG d0HMhyNqsbkhxoWdKpkzVsBKQa7gv6M= X-Google-Smtp-Source: APXvYqxbQ1iX9xkL+ykKQmtdb6votLDk7ltqIa6P2VWxB3TlNt7pVoL5EwTajZbZcJZrgo94OfKR+g== X-Received: by 2002:a5d:4d46:: with SMTP id a6mr4836250wru.196.1571934498255; Thu, 24 Oct 2019 09:28:18 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id r27sm42606124wrc.55.2019.10.24.09.28.17 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Oct 2019 09:28:17 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 41/51] target/arm/kvm: scratch vcpu: Preserve input kvm_vcpu_init features Date: Thu, 24 Oct 2019 17:27:14 +0100 Message-Id: <20191024162724.31675-42-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191024162724.31675-1-peter.maydell@linaro.org> References: <20191024162724.31675-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::42d X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" From: Andrew Jones kvm_arm_create_scratch_host_vcpu() takes a struct kvm_vcpu_init parameter. Rather than just using it as an output parameter to pass back the preferred target, use it also as an input parameter, allowing a caller to pass a selected target if they wish and to also pass cpu features. If the caller doesn't want to select a target they can pass -1 for the target which indicates they want to use the preferred target and have it passed back like before. Signed-off-by: Andrew Jones Reviewed-by: Richard Henderson Reviewed-by: Eric Auger Tested-by: Masayoshi Mizuma Reviewed-by: Beata Michalska Message-id: 20191024121808.9612-8-drjones@redhat.com Signed-off-by: Peter Maydell --- target/arm/kvm.c | 20 +++++++++++++++----- target/arm/kvm32.c | 6 +++++- target/arm/kvm64.c | 6 +++++- 3 files changed, 25 insertions(+), 7 deletions(-) diff --git a/target/arm/kvm.c b/target/arm/kvm.c index f07332bbda3..5b82cefef60 100644 --- a/target/arm/kvm.c +++ b/target/arm/kvm.c @@ -66,7 +66,7 @@ bool kvm_arm_create_scratch_host_vcpu(const uint32_t *cpus_to_try, int *fdarray, struct kvm_vcpu_init *init) { - int ret, kvmfd = -1, vmfd = -1, cpufd = -1; + int ret = 0, kvmfd = -1, vmfd = -1, cpufd = -1; kvmfd = qemu_open("/dev/kvm", O_RDWR); if (kvmfd < 0) { @@ -86,7 +86,14 @@ bool kvm_arm_create_scratch_host_vcpu(const uint32_t *cpus_to_try, goto finish; } - ret = ioctl(vmfd, KVM_ARM_PREFERRED_TARGET, init); + if (init->target == -1) { + struct kvm_vcpu_init preferred; + + ret = ioctl(vmfd, KVM_ARM_PREFERRED_TARGET, &preferred); + if (!ret) { + init->target = preferred.target; + } + } if (ret >= 0) { ret = ioctl(cpufd, KVM_ARM_VCPU_INIT, init); if (ret < 0) { @@ -98,10 +105,12 @@ bool kvm_arm_create_scratch_host_vcpu(const uint32_t *cpus_to_try, * creating one kind of guest CPU which is its preferred * CPU type. */ + struct kvm_vcpu_init try; + while (*cpus_to_try != QEMU_KVM_ARM_TARGET_NONE) { - init->target = *cpus_to_try++; - memset(init->features, 0, sizeof(init->features)); - ret = ioctl(cpufd, KVM_ARM_VCPU_INIT, init); + try.target = *cpus_to_try++; + memcpy(try.features, init->features, sizeof(init->features)); + ret = ioctl(cpufd, KVM_ARM_VCPU_INIT, &try); if (ret >= 0) { break; } @@ -109,6 +118,7 @@ bool kvm_arm_create_scratch_host_vcpu(const uint32_t *cpus_to_try, if (ret < 0) { goto err; } + init->target = try.target; } else { /* Treat a NULL cpus_to_try argument the same as an empty * list, which means we will fail the call since this must diff --git a/target/arm/kvm32.c b/target/arm/kvm32.c index 2451a2d4bbe..32bf8d6757c 100644 --- a/target/arm/kvm32.c +++ b/target/arm/kvm32.c @@ -53,7 +53,11 @@ bool kvm_arm_get_host_cpu_features(ARMHostCPUFeatures *ahcf) QEMU_KVM_ARM_TARGET_CORTEX_A15, QEMU_KVM_ARM_TARGET_NONE }; - struct kvm_vcpu_init init; + /* + * target = -1 informs kvm_arm_create_scratch_host_vcpu() + * to use the preferred target + */ + struct kvm_vcpu_init init = { .target = -1, }; if (!kvm_arm_create_scratch_host_vcpu(cpus_to_try, fdarray, &init)) { return false; diff --git a/target/arm/kvm64.c b/target/arm/kvm64.c index 850da1b5e6a..c7ecefbed72 100644 --- a/target/arm/kvm64.c +++ b/target/arm/kvm64.c @@ -502,7 +502,11 @@ bool kvm_arm_get_host_cpu_features(ARMHostCPUFeatures *ahcf) KVM_ARM_TARGET_CORTEX_A57, QEMU_KVM_ARM_TARGET_NONE }; - struct kvm_vcpu_init init; + /* + * target = -1 informs kvm_arm_create_scratch_host_vcpu() + * to use the preferred target + */ + struct kvm_vcpu_init init = { .target = -1, }; if (!kvm_arm_create_scratch_host_vcpu(cpus_to_try, fdarray, &init)) { return false; From patchwork Thu Oct 24 16:27:15 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 11210531 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C37E6139A for ; Thu, 24 Oct 2019 17:24:04 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 8802820659 for ; Thu, 24 Oct 2019 17:24:04 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="jN1voNpb" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8802820659 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:48650 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNgqA-0000hq-Td for patchwork-qemu-devel@patchwork.kernel.org; Thu, 24 Oct 2019 13:24:02 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58294) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNfyN-0008NO-0Y for qemu-devel@nongnu.org; Thu, 24 Oct 2019 12:28:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iNfyH-00013P-UY for qemu-devel@nongnu.org; Thu, 24 Oct 2019 12:28:25 -0400 Received: from mail-wm1-x331.google.com ([2a00:1450:4864:20::331]:55107) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iNfyH-00012s-Jl for qemu-devel@nongnu.org; Thu, 24 Oct 2019 12:28:21 -0400 Received: by mail-wm1-x331.google.com with SMTP id g7so3537493wmk.4 for ; Thu, 24 Oct 2019 09:28:21 -0700 (PDT) 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=ZeHKzgmsDen/QyhbQuCt1PN7vpHYJaMJAeCb5HkfWO4=; b=jN1voNpbcKFegi2nDzKXHb2cdgjmKyXQxO04khPn9sbRE6uFupbHtDMpxi4oP74EXO Dp6ZUIXhCMOsxwSc1z0OXIlWIwwxfeLx1l4fBUdeQE+6DKHjQRCY/7jL3zVk4g/3F3Jk Kz/DtbyGYBuK66RwWYklZwaRLUGcxgNFlkg7rt9PIcXJ31ZKYIqfWj34uxiCDivUKH5J BXwmrrTHfv9Rs7iIDqg7Ln3KaN6vJNIRbemRhiBpMK3aSl0GHaTvvVW3FNihMsHqp2lf t90Npfk0enXOO585cFLcm25xWJKs/5ezuaQpxmumGLPnp0q2gLMf79HV3eONQRV7kgRp n9yQ== 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=ZeHKzgmsDen/QyhbQuCt1PN7vpHYJaMJAeCb5HkfWO4=; b=l7VnjGfn4+29+964poV64ghVJWDn/dpdbtork40n1k+x/w+5fja6TYiYyRS3h3+PQI O3TzCIWNpavt6d/jxO3MQmhmSR08XbF1p6uqZgnXVRoebKOFlINf0t1qHHGwHlHvrx35 5evMSmwjwP9kt0/h8YXPUwK6PeF+7Av3/WjDcRBSkNKnZPUqlh+GsQ6fTCRV4nMmFwju 3fteBVCin4iJiVicQEdA1u+ejmZEi1mabX+yMJZgVcl0SPkOpzKuNz0FF0V0vVn7x/T3 RYOuUhwk+yOihbhbNe1WpycETcMVherga+bawSn7BngLYriMK7ptb45kiz7FjhW8Uw+H b/qg== X-Gm-Message-State: APjAAAWSgf6RVj4H4c59yEtrCAbDgmGqW6DODnCtQtoFhBtOXv8++uCR VAQkZ+YmFQoFl05K/hhlHLBro1BAcXY= X-Google-Smtp-Source: APXvYqzpC1ClHLRFGj8syCps/APkKeltB9dNQl0JXML2xEOPj9+5wVGigVCMK0Sh4KLs8pQDzeJlJw== X-Received: by 2002:a7b:c05a:: with SMTP id u26mr5679707wmc.128.1571934499751; Thu, 24 Oct 2019 09:28:19 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id r27sm42606124wrc.55.2019.10.24.09.28.18 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Oct 2019 09:28:19 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 42/51] target/arm/cpu64: max cpu: Support sve properties with KVM Date: Thu, 24 Oct 2019 17:27:15 +0100 Message-Id: <20191024162724.31675-43-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191024162724.31675-1-peter.maydell@linaro.org> References: <20191024162724.31675-1-peter.maydell@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::331 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" From: Andrew Jones Extend the SVE vq map initialization and validation with KVM's supported vector lengths when KVM is enabled. In order to determine and select supported lengths we add two new KVM functions for getting and setting the KVM_REG_ARM64_SVE_VLS pseudo-register. This patch has been co-authored with Richard Henderson, who reworked the target/arm/cpu64.c changes in order to push all the validation and auto-enabling/disabling steps into the finalizer, resulting in a nice LOC reduction. Signed-off-by: Andrew Jones Reviewed-by: Eric Auger Reviewed-by: Richard Henderson Tested-by: Masayoshi Mizuma Message-id: 20191024121808.9612-9-drjones@redhat.com Signed-off-by: Peter Maydell --- target/arm/kvm_arm.h | 12 +++ target/arm/cpu64.c | 176 ++++++++++++++++++++++++++++---------- target/arm/kvm64.c | 100 +++++++++++++++++++++- tests/arm-cpu-features.c | 106 ++++++++++++++++++++++- docs/arm-cpu-features.rst | 45 +++++++--- 5 files changed, 381 insertions(+), 58 deletions(-) diff --git a/target/arm/kvm_arm.h b/target/arm/kvm_arm.h index 7c12f1501a8..8e14d400e8a 100644 --- a/target/arm/kvm_arm.h +++ b/target/arm/kvm_arm.h @@ -212,6 +212,17 @@ typedef struct ARMHostCPUFeatures { */ bool kvm_arm_get_host_cpu_features(ARMHostCPUFeatures *ahcf); +/** + * kvm_arm_sve_get_vls: + * @cs: CPUState + * @map: bitmap to fill in + * + * Get all the SVE vector lengths supported by the KVM host, setting + * the bits corresponding to their length in quadwords minus one + * (vq - 1) in @map up to ARM_MAX_VQ. + */ +void kvm_arm_sve_get_vls(CPUState *cs, unsigned long *map); + /** * kvm_arm_set_cpu_features_from_host: * @cpu: ARMCPU to set the features for @@ -316,6 +327,7 @@ static inline int kvm_arm_vgic_probe(void) static inline void kvm_arm_pmu_set_irq(CPUState *cs, int irq) {} static inline void kvm_arm_pmu_init(CPUState *cs) {} +static inline void kvm_arm_sve_get_vls(CPUState *cs, unsigned long *map) {} #endif static inline const char *gic_class_name(void) diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c index a771a28daa5..c161a146ff0 100644 --- a/target/arm/cpu64.c +++ b/target/arm/cpu64.c @@ -273,9 +273,18 @@ void arm_cpu_sve_finalize(ARMCPU *cpu, Error **errp) * any of the above. Finally, if SVE is not disabled, then at least one * vector length must be enabled. */ + DECLARE_BITMAP(kvm_supported, ARM_MAX_VQ); DECLARE_BITMAP(tmp, ARM_MAX_VQ); uint32_t vq, max_vq = 0; + /* Collect the set of vector lengths supported by KVM. */ + bitmap_zero(kvm_supported, ARM_MAX_VQ); + if (kvm_enabled() && kvm_arm_sve_supported(CPU(cpu))) { + kvm_arm_sve_get_vls(CPU(cpu), kvm_supported); + } else if (kvm_enabled()) { + assert(!cpu_isar_feature(aa64_sve, cpu)); + } + /* * Process explicit sve properties. * From the properties, sve_vq_map implies sve_vq_init. @@ -293,10 +302,19 @@ void arm_cpu_sve_finalize(ARMCPU *cpu, Error **errp) return; } - /* Propagate enabled bits down through required powers-of-two. */ - for (vq = pow2floor(max_vq); vq >= 1; vq >>= 1) { - if (!test_bit(vq - 1, cpu->sve_vq_init)) { - set_bit(vq - 1, cpu->sve_vq_map); + if (kvm_enabled()) { + /* + * For KVM we have to automatically enable all supported unitialized + * lengths, even when the smaller lengths are not all powers-of-two. + */ + bitmap_andnot(tmp, kvm_supported, cpu->sve_vq_init, max_vq); + bitmap_or(cpu->sve_vq_map, cpu->sve_vq_map, tmp, max_vq); + } else { + /* Propagate enabled bits down through required powers-of-two. */ + for (vq = pow2floor(max_vq); vq >= 1; vq >>= 1) { + if (!test_bit(vq - 1, cpu->sve_vq_init)) { + set_bit(vq - 1, cpu->sve_vq_map); + } } } } else if (cpu->sve_max_vq == 0) { @@ -308,23 +326,45 @@ void arm_cpu_sve_finalize(ARMCPU *cpu, Error **errp) return; } - /* Disabling a power-of-two disables all larger lengths. */ - if (test_bit(0, cpu->sve_vq_init)) { - error_setg(errp, "cannot disable sve128"); - error_append_hint(errp, "Disabling sve128 results in all vector " - "lengths being disabled.\n"); - error_append_hint(errp, "With SVE enabled, at least one vector " - "length must be enabled.\n"); - return; - } - for (vq = 2; vq <= ARM_MAX_VQ; vq <<= 1) { - if (test_bit(vq - 1, cpu->sve_vq_init)) { - break; + if (kvm_enabled()) { + /* Disabling a supported length disables all larger lengths. */ + for (vq = 1; vq <= ARM_MAX_VQ; ++vq) { + if (test_bit(vq - 1, cpu->sve_vq_init) && + test_bit(vq - 1, kvm_supported)) { + break; + } } + max_vq = vq <= ARM_MAX_VQ ? vq - 1 : ARM_MAX_VQ; + bitmap_andnot(cpu->sve_vq_map, kvm_supported, + cpu->sve_vq_init, max_vq); + if (max_vq == 0 || bitmap_empty(cpu->sve_vq_map, max_vq)) { + error_setg(errp, "cannot disable sve%d", vq * 128); + error_append_hint(errp, "Disabling sve%d results in all " + "vector lengths being disabled.\n", + vq * 128); + error_append_hint(errp, "With SVE enabled, at least one " + "vector length must be enabled.\n"); + return; + } + } else { + /* Disabling a power-of-two disables all larger lengths. */ + if (test_bit(0, cpu->sve_vq_init)) { + error_setg(errp, "cannot disable sve128"); + error_append_hint(errp, "Disabling sve128 results in all " + "vector lengths being disabled.\n"); + error_append_hint(errp, "With SVE enabled, at least one " + "vector length must be enabled.\n"); + return; + } + for (vq = 2; vq <= ARM_MAX_VQ; vq <<= 1) { + if (test_bit(vq - 1, cpu->sve_vq_init)) { + break; + } + } + max_vq = vq <= ARM_MAX_VQ ? vq - 1 : ARM_MAX_VQ; + bitmap_complement(cpu->sve_vq_map, cpu->sve_vq_init, max_vq); } - max_vq = vq <= ARM_MAX_VQ ? vq - 1 : ARM_MAX_VQ; - bitmap_complement(cpu->sve_vq_map, cpu->sve_vq_init, max_vq); max_vq = find_last_bit(cpu->sve_vq_map, max_vq) + 1; } @@ -358,16 +398,48 @@ void arm_cpu_sve_finalize(ARMCPU *cpu, Error **errp) assert(max_vq != 0); bitmap_clear(cpu->sve_vq_map, max_vq, ARM_MAX_VQ - max_vq); - /* Ensure all required powers-of-two are enabled. */ - for (vq = pow2floor(max_vq); vq >= 1; vq >>= 1) { - if (!test_bit(vq - 1, cpu->sve_vq_map)) { - error_setg(errp, "cannot disable sve%d", vq * 128); - error_append_hint(errp, "sve%d is required as it " - "is a power-of-two length smaller than " - "the maximum, sve%d\n", - vq * 128, max_vq * 128); + if (kvm_enabled()) { + /* Ensure the set of lengths matches what KVM supports. */ + bitmap_xor(tmp, cpu->sve_vq_map, kvm_supported, max_vq); + if (!bitmap_empty(tmp, max_vq)) { + vq = find_last_bit(tmp, max_vq) + 1; + if (test_bit(vq - 1, cpu->sve_vq_map)) { + if (cpu->sve_max_vq) { + error_setg(errp, "cannot set sve-max-vq=%d", + cpu->sve_max_vq); + error_append_hint(errp, "This KVM host does not support " + "the vector length %d-bits.\n", + vq * 128); + error_append_hint(errp, "It may not be possible to use " + "sve-max-vq with this KVM host. Try " + "using only sve properties.\n"); + } else { + error_setg(errp, "cannot enable sve%d", vq * 128); + error_append_hint(errp, "This KVM host does not support " + "the vector length %d-bits.\n", + vq * 128); + } + } else { + error_setg(errp, "cannot disable sve%d", vq * 128); + error_append_hint(errp, "The KVM host requires all " + "supported vector lengths smaller " + "than %d bits to also be enabled.\n", + max_vq * 128); + } return; } + } else { + /* Ensure all required powers-of-two are enabled. */ + for (vq = pow2floor(max_vq); vq >= 1; vq >>= 1) { + if (!test_bit(vq - 1, cpu->sve_vq_map)) { + error_setg(errp, "cannot disable sve%d", vq * 128); + error_append_hint(errp, "sve%d is required as it " + "is a power-of-two length smaller than " + "the maximum, sve%d\n", + vq * 128, max_vq * 128); + return; + } + } } /* @@ -421,15 +493,28 @@ static void cpu_max_set_sve_max_vq(Object *obj, Visitor *v, const char *name, { ARMCPU *cpu = ARM_CPU(obj); Error *err = NULL; + uint32_t max_vq; - visit_type_uint32(v, name, &cpu->sve_max_vq, &err); - - if (!err && (cpu->sve_max_vq == 0 || cpu->sve_max_vq > ARM_MAX_VQ)) { - error_setg(&err, "unsupported SVE vector length"); - error_append_hint(&err, "Valid sve-max-vq in range [1-%d]\n", - ARM_MAX_VQ); + visit_type_uint32(v, name, &max_vq, &err); + if (err) { + error_propagate(errp, err); + return; } - error_propagate(errp, err); + + if (kvm_enabled() && !kvm_arm_sve_supported(CPU(cpu))) { + error_setg(errp, "cannot set sve-max-vq"); + error_append_hint(errp, "SVE not supported by KVM on this host\n"); + return; + } + + if (max_vq == 0 || max_vq > ARM_MAX_VQ) { + error_setg(errp, "unsupported SVE vector length"); + error_append_hint(errp, "Valid sve-max-vq in range [1-%d]\n", + ARM_MAX_VQ); + return; + } + + cpu->sve_max_vq = max_vq; } static void cpu_arm_get_sve_vq(Object *obj, Visitor *v, const char *name, @@ -462,6 +547,12 @@ static void cpu_arm_set_sve_vq(Object *obj, Visitor *v, const char *name, return; } + if (value && kvm_enabled() && !kvm_arm_sve_supported(CPU(cpu))) { + error_setg(errp, "cannot enable %s", name); + error_append_hint(errp, "SVE not supported by KVM on this host\n"); + return; + } + if (value) { set_bit(vq - 1, cpu->sve_vq_map); } else { @@ -619,20 +710,19 @@ static void aarch64_max_initfn(Object *obj) cpu->ctr = 0x80038003; /* 32 byte I and D cacheline size, VIPT icache */ cpu->dcz_blocksize = 7; /* 512 bytes */ #endif - - object_property_add(obj, "sve-max-vq", "uint32", cpu_max_get_sve_max_vq, - cpu_max_set_sve_max_vq, NULL, NULL, &error_fatal); - - for (vq = 1; vq <= ARM_MAX_VQ; ++vq) { - char name[8]; - sprintf(name, "sve%d", vq * 128); - object_property_add(obj, name, "bool", cpu_arm_get_sve_vq, - cpu_arm_set_sve_vq, NULL, NULL, &error_fatal); - } } object_property_add(obj, "sve", "bool", cpu_arm_get_sve, cpu_arm_set_sve, NULL, NULL, &error_fatal); + object_property_add(obj, "sve-max-vq", "uint32", cpu_max_get_sve_max_vq, + cpu_max_set_sve_max_vq, NULL, NULL, &error_fatal); + + for (vq = 1; vq <= ARM_MAX_VQ; ++vq) { + char name[8]; + sprintf(name, "sve%d", vq * 128); + object_property_add(obj, name, "bool", cpu_arm_get_sve_vq, + cpu_arm_set_sve_vq, NULL, NULL, &error_fatal); + } } struct ARMCPUInfo { diff --git a/target/arm/kvm64.c b/target/arm/kvm64.c index c7ecefbed72..c93bbee425a 100644 --- a/target/arm/kvm64.c +++ b/target/arm/kvm64.c @@ -613,6 +613,100 @@ bool kvm_arm_sve_supported(CPUState *cpu) return kvm_check_extension(s, KVM_CAP_ARM_SVE); } +QEMU_BUILD_BUG_ON(KVM_ARM64_SVE_VQ_MIN != 1); + +void kvm_arm_sve_get_vls(CPUState *cs, unsigned long *map) +{ + /* Only call this function if kvm_arm_sve_supported() returns true. */ + static uint64_t vls[KVM_ARM64_SVE_VLS_WORDS]; + static bool probed; + uint32_t vq = 0; + int i, j; + + bitmap_clear(map, 0, ARM_MAX_VQ); + + /* + * KVM ensures all host CPUs support the same set of vector lengths. + * So we only need to create the scratch VCPUs once and then cache + * the results. + */ + if (!probed) { + struct kvm_vcpu_init init = { + .target = -1, + .features[0] = (1 << KVM_ARM_VCPU_SVE), + }; + struct kvm_one_reg reg = { + .id = KVM_REG_ARM64_SVE_VLS, + .addr = (uint64_t)&vls[0], + }; + int fdarray[3], ret; + + probed = true; + + if (!kvm_arm_create_scratch_host_vcpu(NULL, fdarray, &init)) { + error_report("failed to create scratch VCPU with SVE enabled"); + abort(); + } + ret = ioctl(fdarray[2], KVM_GET_ONE_REG, ®); + kvm_arm_destroy_scratch_host_vcpu(fdarray); + if (ret) { + error_report("failed to get KVM_REG_ARM64_SVE_VLS: %s", + strerror(errno)); + abort(); + } + + for (i = KVM_ARM64_SVE_VLS_WORDS - 1; i >= 0; --i) { + if (vls[i]) { + vq = 64 - clz64(vls[i]) + i * 64; + break; + } + } + if (vq > ARM_MAX_VQ) { + warn_report("KVM supports vector lengths larger than " + "QEMU can enable"); + } + } + + for (i = 0; i < KVM_ARM64_SVE_VLS_WORDS; ++i) { + if (!vls[i]) { + continue; + } + for (j = 1; j <= 64; ++j) { + vq = j + i * 64; + if (vq > ARM_MAX_VQ) { + return; + } + if (vls[i] & (1UL << (j - 1))) { + set_bit(vq - 1, map); + } + } + } +} + +static int kvm_arm_sve_set_vls(CPUState *cs) +{ + uint64_t vls[KVM_ARM64_SVE_VLS_WORDS] = {0}; + struct kvm_one_reg reg = { + .id = KVM_REG_ARM64_SVE_VLS, + .addr = (uint64_t)&vls[0], + }; + ARMCPU *cpu = ARM_CPU(cs); + uint32_t vq; + int i, j; + + assert(cpu->sve_max_vq <= KVM_ARM64_SVE_VQ_MAX); + + for (vq = 1; vq <= cpu->sve_max_vq; ++vq) { + if (test_bit(vq - 1, cpu->sve_vq_map)) { + i = (vq - 1) / 64; + j = (vq - 1) % 64; + vls[i] |= 1UL << j; + } + } + + return kvm_vcpu_ioctl(cs, KVM_SET_ONE_REG, ®); +} + #define ARM_CPU_ID_MPIDR 3, 0, 0, 0, 5 int kvm_arch_init_vcpu(CPUState *cs) @@ -624,7 +718,7 @@ int kvm_arch_init_vcpu(CPUState *cs) if (cpu->kvm_target == QEMU_KVM_ARM_TARGET_NONE || !object_dynamic_cast(OBJECT(cpu), TYPE_AARCH64_CPU)) { - fprintf(stderr, "KVM is not supported for this guest CPU type\n"); + error_report("KVM is not supported for this guest CPU type"); return -EINVAL; } @@ -660,6 +754,10 @@ int kvm_arch_init_vcpu(CPUState *cs) } if (cpu_isar_feature(aa64_sve, cpu)) { + ret = kvm_arm_sve_set_vls(cs); + if (ret) { + return ret; + } ret = kvm_arm_vcpu_finalize(cs, KVM_ARM_VCPU_SVE); if (ret) { return ret; diff --git a/tests/arm-cpu-features.c b/tests/arm-cpu-features.c index 3efc168d62a..597c1cd78db 100644 --- a/tests/arm-cpu-features.c +++ b/tests/arm-cpu-features.c @@ -112,6 +112,17 @@ static QDict *resp_get_props(QDict *resp) return qdict; } +static bool resp_get_feature(QDict *resp, const char *feature) +{ + QDict *props; + + g_assert(resp); + g_assert(resp_has_props(resp)); + props = resp_get_props(resp); + g_assert(qdict_get(props, feature)); + return qdict_get_bool(props, feature); +} + #define assert_has_feature(qts, cpu_type, feature) \ ({ \ QDict *_resp = do_query_no_props(qts, cpu_type); \ @@ -341,6 +352,25 @@ static void sve_tests_sve_off(const void *data) qtest_quit(qts); } +static void sve_tests_sve_off_kvm(const void *data) +{ + QTestState *qts; + + qts = qtest_init(MACHINE "-accel kvm -cpu max,sve=off"); + + /* + * We don't know if this host supports SVE so we don't + * attempt to test enabling anything. We only test that + * everything is disabled (as it should be with sve=off) + * and that using sve=off to explicitly disable vector + * lengths is OK too. + */ + assert_sve_vls(qts, "max", 0, NULL); + assert_sve_vls(qts, "max", 0, "{ 'sve128': false }"); + + qtest_quit(qts); +} + static void test_query_cpu_model_expansion(const void *data) { QTestState *qts; @@ -388,14 +418,82 @@ static void test_query_cpu_model_expansion_kvm(const void *data) qts = qtest_init(MACHINE "-accel kvm -cpu host"); if (g_str_equal(qtest_get_arch(), "aarch64")) { + bool kvm_supports_sve; + char max_name[8], name[8]; + uint32_t max_vq, vq; + uint64_t vls; + QDict *resp; + char *error; + assert_has_feature(qts, "host", "aarch64"); assert_has_feature(qts, "host", "pmu"); - assert_has_feature(qts, "max", "sve"); - assert_error(qts, "cortex-a15", "We cannot guarantee the CPU type 'cortex-a15' works " "with KVM on this host", NULL); + + assert_has_feature(qts, "max", "sve"); + resp = do_query_no_props(qts, "max"); + kvm_supports_sve = resp_get_feature(resp, "sve"); + vls = resp_get_sve_vls(resp); + qobject_unref(resp); + + if (kvm_supports_sve) { + g_assert(vls != 0); + max_vq = 64 - __builtin_clzll(vls); + sprintf(max_name, "sve%d", max_vq * 128); + + /* Enabling a supported length is of course fine. */ + assert_sve_vls(qts, "max", vls, "{ %s: true }", max_name); + + /* Get the next supported length smaller than max-vq. */ + vq = 64 - __builtin_clzll(vls & ~BIT_ULL(max_vq - 1)); + if (vq) { + /* + * We have at least one length smaller than max-vq, + * so we can disable max-vq. + */ + assert_sve_vls(qts, "max", (vls & ~BIT_ULL(max_vq - 1)), + "{ %s: false }", max_name); + + /* + * Smaller, supported vector lengths cannot be disabled + * unless all larger, supported vector lengths are also + * disabled. + */ + sprintf(name, "sve%d", vq * 128); + error = g_strdup_printf("cannot disable %s", name); + assert_error(qts, "max", error, + "{ %s: true, %s: false }", + max_name, name); + g_free(error); + } + + /* + * The smallest, supported vector length is required, because + * we need at least one vector length enabled. + */ + vq = __builtin_ffsll(vls); + sprintf(name, "sve%d", vq * 128); + error = g_strdup_printf("cannot disable %s", name); + assert_error(qts, "max", error, "{ %s: false }", name); + g_free(error); + + /* Get an unsupported length. */ + for (vq = 1; vq <= max_vq; ++vq) { + if (!(vls & BIT_ULL(vq - 1))) { + break; + } + } + if (vq <= SVE_MAX_VQ) { + sprintf(name, "sve%d", vq * 128); + error = g_strdup_printf("cannot enable %s", name); + assert_error(qts, "max", error, "{ %s: true }", name); + g_free(error); + } + } else { + g_assert(vls == 0); + } } else { assert_has_not_feature(qts, "host", "aarch64"); assert_has_not_feature(qts, "host", "pmu"); @@ -433,6 +531,10 @@ int main(int argc, char **argv) if (kvm_available) { qtest_add_data_func("/arm/kvm/query-cpu-model-expansion", NULL, test_query_cpu_model_expansion_kvm); + if (g_str_equal(qtest_get_arch(), "aarch64")) { + qtest_add_data_func("/arm/kvm/query-cpu-model-expansion/sve-off", + NULL, sve_tests_sve_off_kvm); + } } return g_test_run(); diff --git a/docs/arm-cpu-features.rst b/docs/arm-cpu-features.rst index 2ea4d6e90c0..bed218d4461 100644 --- a/docs/arm-cpu-features.rst +++ b/docs/arm-cpu-features.rst @@ -191,10 +191,18 @@ SVE CPU Property Dependencies and Constraints 1) At least one vector length must be enabled when `sve` is enabled. - 2) If a vector length `N` is enabled, then all power-of-two vector - lengths smaller than `N` must also be enabled. E.g. if `sve512` - is enabled, then the 128-bit and 256-bit vector lengths must also - be enabled. + 2) If a vector length `N` is enabled, then, when KVM is enabled, all + smaller, host supported vector lengths must also be enabled. If + KVM is not enabled, then only all the smaller, power-of-two vector + lengths must be enabled. E.g. with KVM if the host supports all + vector lengths up to 512-bits (128, 256, 384, 512), then if `sve512` + is enabled, the 128-bit vector length, 256-bit vector length, and + 384-bit vector length must also be enabled. Without KVM, the 384-bit + vector length would not be required. + + 3) If KVM is enabled then only vector lengths that the host CPU type + support may be enabled. If SVE is not supported by the host, then + no `sve*` properties may be enabled. SVE CPU Property Parsing Semantics ---------------------------------- @@ -209,8 +217,10 @@ SVE CPU Property Parsing Semantics an error is generated. 2) If SVE is enabled (`sve=on`), but no `sve` CPU properties are - provided, then all supported vector lengths are enabled, including - the non-power-of-two lengths. + provided, then all supported vector lengths are enabled, which when + KVM is not in use means including the non-power-of-two lengths, and, + when KVM is in use, it means all vector lengths supported by the host + processor. 3) If SVE is enabled, then an error is generated when attempting to disable the last enabled vector length (see constraint (1) of "SVE @@ -221,20 +231,31 @@ SVE CPU Property Parsing Semantics has been explicitly disabled, then an error is generated (see constraint (2) of "SVE CPU Property Dependencies and Constraints"). - 5) If one or more `sve` CPU properties are set `off`, but no `sve`, + 5) When KVM is enabled, if the host does not support SVE, then an error + is generated when attempting to enable any `sve*` properties (see + constraint (3) of "SVE CPU Property Dependencies and Constraints"). + + 6) When KVM is enabled, if the host does support SVE, then an error is + generated when attempting to enable any vector lengths not supported + by the host (see constraint (3) of "SVE CPU Property Dependencies and + Constraints"). + + 7) If one or more `sve` CPU properties are set `off`, but no `sve`, CPU properties are set `on`, then the specified vector lengths are disabled but the default for any unspecified lengths remains enabled. - Disabling a power-of-two vector length also disables all vector - lengths larger than the power-of-two length (see constraint (2) of - "SVE CPU Property Dependencies and Constraints"). + When KVM is not enabled, disabling a power-of-two vector length also + disables all vector lengths larger than the power-of-two length. + When KVM is enabled, then disabling any supported vector length also + disables all larger vector lengths (see constraint (2) of "SVE CPU + Property Dependencies and Constraints"). - 6) If one or more `sve` CPU properties are set to `on`, then they + 8) If one or more `sve` CPU properties are set to `on`, then they are enabled and all unspecified lengths default to disabled, except for the required lengths per constraint (2) of "SVE CPU Property Dependencies and Constraints", which will even be auto-enabled if they were not explicitly enabled. - 7) If SVE was disabled (`sve=off`), allowing all vector lengths to be + 9) If SVE was disabled (`sve=off`), allowing all vector lengths to be explicitly disabled (i.e. avoiding the error specified in (3) of "SVE CPU Property Parsing Semantics"), then if later an `sve=on` is provided an error will be generated. To avoid this error, one must From patchwork Thu Oct 24 16:27:16 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 11210487 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E8391139A for ; Thu, 24 Oct 2019 17:19:11 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id ADEBC20659 for ; Thu, 24 Oct 2019 17:19:11 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="OgbaTaSB" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org ADEBC20659 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:48530 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNglS-0004sX-6s for patchwork-qemu-devel@patchwork.kernel.org; Thu, 24 Oct 2019 13:19:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58287) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNfyL-0008MN-Mb for qemu-devel@nongnu.org; Thu, 24 Oct 2019 12:28:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iNfyI-00013s-IJ for qemu-devel@nongnu.org; Thu, 24 Oct 2019 12:28:25 -0400 Received: from mail-wm1-x32f.google.com ([2a00:1450:4864:20::32f]:56230) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iNfyI-000131-B8 for qemu-devel@nongnu.org; Thu, 24 Oct 2019 12:28:22 -0400 Received: by mail-wm1-x32f.google.com with SMTP id g24so3536613wmh.5 for ; Thu, 24 Oct 2019 09:28:22 -0700 (PDT) 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=wSFmtC946G7bKfZfsaz2Gf6yL4qS0CVGiz6hotSxhvk=; b=OgbaTaSBHf1tapIv/KFmg4TfMWuhcqU07cqwq063aoce76m2kRxXnfqPV0ldBA9i42 i7MBEnEEQvzbWpVqaxopQLWE1Ik2pYGoNmIHc7fMgJIar3YKQ7QLY7mjFwsYtRg6OPwg 5kgLAJkloiMiry/nK+JXzLS5waljKCRWpEdaV1XFUid3zeeu0HpN6odWE6bGzerypzjD QxLtx/Z7E5KOUmnnxZy1ZVnJBg5z1fkGlUIPnnGS3N9mIp8L8D92Rz5J8PQg/NXJx7m0 eWLSdH+xLQ8RnzxVr2awB1/m9sVF1y3hkgIc10uhk1aL/085G1QP5kHIETWXHk64Q5Hg D2mw== 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=wSFmtC946G7bKfZfsaz2Gf6yL4qS0CVGiz6hotSxhvk=; b=m0u7Wb+Og8zqrh5vSkuCPbTLgzZ5WaQOTE2vXRhbVeLiQ/HfALvalsWGtwKlyuvhV/ j1Jzog4HbhnTRynManqq+TEk4J2FnvXC700/wDeMyp7wW7kjUDNUu9wGinQwMYviwthS vpDspPDItAUpM8PLzKYep7e9Hez70YQtVuAO4QQhKdXaS1WVT8nqu8aeqQMcTbJ/EZJD oxPEsygK4SPj8/X2pnBo9D5wvHs5H8cH39hBewpW6Mljkkmmo8WC9Sk8agXaoTvUi/9h t2CTYsMgdWOP1L60MOslmBqHfjcRGWdbOABKKuKYwUDBqOGwxwsVNnMNTx4Gd4LJeNum h7MA== X-Gm-Message-State: APjAAAW4Kmm/ljPGF2WOussu2G1SaRfBdWMApmGfY/3iXaR3rdauIvqR receQ8BFkPlbnKSx4oeQxPzL8wfNwac= X-Google-Smtp-Source: APXvYqwGWBPr7lZQ31ywwed/6tj7mLkBKS+PKSb2q0a6yj6P3qU9pnoNqcwobrzMRXE+t5cKWplWDQ== X-Received: by 2002:a7b:cd04:: with SMTP id f4mr5643565wmj.91.1571934500868; Thu, 24 Oct 2019 09:28:20 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id r27sm42606124wrc.55.2019.10.24.09.28.19 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Oct 2019 09:28:20 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 43/51] target/arm/kvm: host cpu: Add support for sve properties Date: Thu, 24 Oct 2019 17:27:16 +0100 Message-Id: <20191024162724.31675-44-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191024162724.31675-1-peter.maydell@linaro.org> References: <20191024162724.31675-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::32f X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" From: Andrew Jones Allow cpu 'host' to enable SVE when it's available, unless the user chooses to disable it with the added 'sve=off' cpu property. Also give the user the ability to select vector lengths with the sve properties. We don't adopt 'max' cpu's other sve property, sve-max-vq, because that property is difficult to use with KVM. That property assumes all vector lengths in the range from 1 up to and including the specified maximum length are supported, but there may be optional lengths not supported by the host in that range. With KVM one must be more specific when enabling vector lengths. Signed-off-by: Andrew Jones Reviewed-by: Eric Auger Reviewed-by: Richard Henderson Tested-by: Masayoshi Mizuma Message-id: 20191024121808.9612-10-drjones@redhat.com Signed-off-by: Peter Maydell --- target/arm/cpu.h | 2 ++ target/arm/cpu.c | 3 +++ target/arm/cpu64.c | 33 +++++++++++++++++---------------- target/arm/kvm64.c | 14 +++++++++++++- tests/arm-cpu-features.c | 23 +++++++++++------------ docs/arm-cpu-features.rst | 19 ++++++++++++------- 6 files changed, 58 insertions(+), 36 deletions(-) diff --git a/target/arm/cpu.h b/target/arm/cpu.h index a044d6028b6..e1a66a2d1cc 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -977,11 +977,13 @@ int aarch64_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg); void aarch64_sve_narrow_vq(CPUARMState *env, unsigned vq); void aarch64_sve_change_el(CPUARMState *env, int old_el, int new_el, bool el0_a64); +void aarch64_add_sve_properties(Object *obj); #else static inline void aarch64_sve_narrow_vq(CPUARMState *env, unsigned vq) { } static inline void aarch64_sve_change_el(CPUARMState *env, int o, int n, bool a) { } +static inline void aarch64_add_sve_properties(Object *obj) { } #endif #if !defined(CONFIG_TCG) diff --git a/target/arm/cpu.c b/target/arm/cpu.c index 17d1f2b2894..7a4ac9339bf 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -2670,6 +2670,9 @@ static void arm_host_initfn(Object *obj) ARMCPU *cpu = ARM_CPU(obj); kvm_arm_set_cpu_features_from_host(cpu); + if (arm_feature(&cpu->env, ARM_FEATURE_AARCH64)) { + aarch64_add_sve_properties(obj); + } arm_cpu_post_init(obj); } diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c index c161a146ff0..68baf0482ff 100644 --- a/target/arm/cpu64.c +++ b/target/arm/cpu64.c @@ -594,6 +594,21 @@ static void cpu_arm_set_sve(Object *obj, Visitor *v, const char *name, cpu->isar.id_aa64pfr0 = t; } +void aarch64_add_sve_properties(Object *obj) +{ + uint32_t vq; + + object_property_add(obj, "sve", "bool", cpu_arm_get_sve, + cpu_arm_set_sve, NULL, NULL, &error_fatal); + + for (vq = 1; vq <= ARM_MAX_VQ; ++vq) { + char name[8]; + sprintf(name, "sve%d", vq * 128); + object_property_add(obj, name, "bool", cpu_arm_get_sve_vq, + cpu_arm_set_sve_vq, NULL, NULL, &error_fatal); + } +} + /* -cpu max: if KVM is enabled, like -cpu host (best possible with this host); * otherwise, a CPU with as many features enabled as our emulation supports. * The version of '-cpu max' for qemu-system-arm is defined in cpu.c; @@ -602,17 +617,11 @@ static void cpu_arm_set_sve(Object *obj, Visitor *v, const char *name, static void aarch64_max_initfn(Object *obj) { ARMCPU *cpu = ARM_CPU(obj); - uint32_t vq; - uint64_t t; if (kvm_enabled()) { kvm_arm_set_cpu_features_from_host(cpu); - if (kvm_arm_sve_supported(CPU(cpu))) { - t = cpu->isar.id_aa64pfr0; - t = FIELD_DP64(t, ID_AA64PFR0, SVE, 1); - cpu->isar.id_aa64pfr0 = t; - } } else { + uint64_t t; uint32_t u; aarch64_a57_initfn(obj); @@ -712,17 +721,9 @@ static void aarch64_max_initfn(Object *obj) #endif } - object_property_add(obj, "sve", "bool", cpu_arm_get_sve, - cpu_arm_set_sve, NULL, NULL, &error_fatal); + aarch64_add_sve_properties(obj); object_property_add(obj, "sve-max-vq", "uint32", cpu_max_get_sve_max_vq, cpu_max_set_sve_max_vq, NULL, NULL, &error_fatal); - - for (vq = 1; vq <= ARM_MAX_VQ; ++vq) { - char name[8]; - sprintf(name, "sve%d", vq * 128); - object_property_add(obj, name, "bool", cpu_arm_get_sve_vq, - cpu_arm_set_sve_vq, NULL, NULL, &error_fatal); - } } struct ARMCPUInfo { diff --git a/target/arm/kvm64.c b/target/arm/kvm64.c index c93bbee425a..876184b8fe4 100644 --- a/target/arm/kvm64.c +++ b/target/arm/kvm64.c @@ -488,7 +488,9 @@ bool kvm_arm_get_host_cpu_features(ARMHostCPUFeatures *ahcf) * and then query that CPU for the relevant ID registers. */ int fdarray[3]; + bool sve_supported; uint64_t features = 0; + uint64_t t; int err; /* Old kernels may not know about the PREFERRED_TARGET ioctl: however @@ -578,13 +580,23 @@ bool kvm_arm_get_host_cpu_features(ARMHostCPUFeatures *ahcf) ARM64_SYS_REG(3, 0, 0, 3, 2)); } + sve_supported = ioctl(fdarray[0], KVM_CHECK_EXTENSION, KVM_CAP_ARM_SVE) > 0; + kvm_arm_destroy_scratch_host_vcpu(fdarray); if (err < 0) { return false; } - /* We can assume any KVM supporting CPU is at least a v8 + /* Add feature bits that can't appear until after VCPU init. */ + if (sve_supported) { + t = ahcf->isar.id_aa64pfr0; + t = FIELD_DP64(t, ID_AA64PFR0, SVE, 1); + ahcf->isar.id_aa64pfr0 = t; + } + + /* + * We can assume any KVM supporting CPU is at least a v8 * with VFPv4+Neon; this in turn implies most of the other * feature bits. */ diff --git a/tests/arm-cpu-features.c b/tests/arm-cpu-features.c index 597c1cd78db..6b8c48de8aa 100644 --- a/tests/arm-cpu-features.c +++ b/tests/arm-cpu-features.c @@ -356,7 +356,7 @@ static void sve_tests_sve_off_kvm(const void *data) { QTestState *qts; - qts = qtest_init(MACHINE "-accel kvm -cpu max,sve=off"); + qts = qtest_init(MACHINE "-accel kvm -cpu host,sve=off"); /* * We don't know if this host supports SVE so we don't @@ -365,8 +365,8 @@ static void sve_tests_sve_off_kvm(const void *data) * and that using sve=off to explicitly disable vector * lengths is OK too. */ - assert_sve_vls(qts, "max", 0, NULL); - assert_sve_vls(qts, "max", 0, "{ 'sve128': false }"); + assert_sve_vls(qts, "host", 0, NULL); + assert_sve_vls(qts, "host", 0, "{ 'sve128': false }"); qtest_quit(qts); } @@ -432,8 +432,8 @@ static void test_query_cpu_model_expansion_kvm(const void *data) "We cannot guarantee the CPU type 'cortex-a15' works " "with KVM on this host", NULL); - assert_has_feature(qts, "max", "sve"); - resp = do_query_no_props(qts, "max"); + assert_has_feature(qts, "host", "sve"); + resp = do_query_no_props(qts, "host"); kvm_supports_sve = resp_get_feature(resp, "sve"); vls = resp_get_sve_vls(resp); qobject_unref(resp); @@ -444,7 +444,7 @@ static void test_query_cpu_model_expansion_kvm(const void *data) sprintf(max_name, "sve%d", max_vq * 128); /* Enabling a supported length is of course fine. */ - assert_sve_vls(qts, "max", vls, "{ %s: true }", max_name); + assert_sve_vls(qts, "host", vls, "{ %s: true }", max_name); /* Get the next supported length smaller than max-vq. */ vq = 64 - __builtin_clzll(vls & ~BIT_ULL(max_vq - 1)); @@ -453,7 +453,7 @@ static void test_query_cpu_model_expansion_kvm(const void *data) * We have at least one length smaller than max-vq, * so we can disable max-vq. */ - assert_sve_vls(qts, "max", (vls & ~BIT_ULL(max_vq - 1)), + assert_sve_vls(qts, "host", (vls & ~BIT_ULL(max_vq - 1)), "{ %s: false }", max_name); /* @@ -463,7 +463,7 @@ static void test_query_cpu_model_expansion_kvm(const void *data) */ sprintf(name, "sve%d", vq * 128); error = g_strdup_printf("cannot disable %s", name); - assert_error(qts, "max", error, + assert_error(qts, "host", error, "{ %s: true, %s: false }", max_name, name); g_free(error); @@ -476,7 +476,7 @@ static void test_query_cpu_model_expansion_kvm(const void *data) vq = __builtin_ffsll(vls); sprintf(name, "sve%d", vq * 128); error = g_strdup_printf("cannot disable %s", name); - assert_error(qts, "max", error, "{ %s: false }", name); + assert_error(qts, "host", error, "{ %s: false }", name); g_free(error); /* Get an unsupported length. */ @@ -488,7 +488,7 @@ static void test_query_cpu_model_expansion_kvm(const void *data) if (vq <= SVE_MAX_VQ) { sprintf(name, "sve%d", vq * 128); error = g_strdup_printf("cannot enable %s", name); - assert_error(qts, "max", error, "{ %s: true }", name); + assert_error(qts, "host", error, "{ %s: true }", name); g_free(error); } } else { @@ -497,8 +497,7 @@ static void test_query_cpu_model_expansion_kvm(const void *data) } else { assert_has_not_feature(qts, "host", "aarch64"); assert_has_not_feature(qts, "host", "pmu"); - - assert_has_not_feature(qts, "max", "sve"); + assert_has_not_feature(qts, "host", "sve"); } qtest_quit(qts); diff --git a/docs/arm-cpu-features.rst b/docs/arm-cpu-features.rst index bed218d4461..1b367e22e16 100644 --- a/docs/arm-cpu-features.rst +++ b/docs/arm-cpu-features.rst @@ -272,31 +272,36 @@ SVE CPU Property Examples $ qemu-system-aarch64 -M virt -cpu max - 3) Only enable the 128-bit vector length:: + 3) When KVM is enabled, implicitly enable all host CPU supported vector + lengths with the `host` CPU type:: + + $ qemu-system-aarch64 -M virt,accel=kvm -cpu host + + 4) Only enable the 128-bit vector length:: $ qemu-system-aarch64 -M virt -cpu max,sve128=on - 4) Disable the 512-bit vector length and all larger vector lengths, + 5) Disable the 512-bit vector length and all larger vector lengths, since 512 is a power-of-two. This results in all the smaller, uninitialized lengths (128, 256, and 384) defaulting to enabled:: $ qemu-system-aarch64 -M virt -cpu max,sve512=off - 5) Enable the 128-bit, 256-bit, and 512-bit vector lengths:: + 6) Enable the 128-bit, 256-bit, and 512-bit vector lengths:: $ qemu-system-aarch64 -M virt -cpu max,sve128=on,sve256=on,sve512=on - 6) The same as (5), but since the 128-bit and 256-bit vector + 7) The same as (6), but since the 128-bit and 256-bit vector lengths are required for the 512-bit vector length to be enabled, then allow them to be auto-enabled:: $ qemu-system-aarch64 -M virt -cpu max,sve512=on - 7) Do the same as (6), but by first disabling SVE and then re-enabling it:: + 8) Do the same as (7), but by first disabling SVE and then re-enabling it:: $ qemu-system-aarch64 -M virt -cpu max,sve=off,sve512=on,sve=on - 8) Force errors regarding the last vector length:: + 9) Force errors regarding the last vector length:: $ qemu-system-aarch64 -M virt -cpu max,sve128=off $ qemu-system-aarch64 -M virt -cpu max,sve=off,sve128=off,sve=on @@ -308,5 +313,5 @@ The examples in "SVE CPU Property Examples" exhibit many ways to select vector lengths which developers may find useful in order to avoid overly verbose command lines. However, the recommended way to select vector lengths is to explicitly enable each desired length. Therefore only -example's (1), (3), and (5) exhibit recommended uses of the properties. +example's (1), (4), and (6) exhibit recommended uses of the properties. From patchwork Thu Oct 24 16:27:17 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 11210557 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 69ED71575 for ; Thu, 24 Oct 2019 17:31:03 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 3FCBE205C9 for ; Thu, 24 Oct 2019 17:31:03 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="bJ4jbhhc" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3FCBE205C9 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:48796 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNgwu-0000YV-H2 for patchwork-qemu-devel@patchwork.kernel.org; Thu, 24 Oct 2019 13:31:00 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58284) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNfyL-0008Lu-HJ for qemu-devel@nongnu.org; Thu, 24 Oct 2019 12:28:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iNfyJ-00014p-Vs for qemu-devel@nongnu.org; Thu, 24 Oct 2019 12:28:25 -0400 Received: from mail-wr1-x429.google.com ([2a00:1450:4864:20::429]:45724) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iNfyJ-00014L-Oo for qemu-devel@nongnu.org; Thu, 24 Oct 2019 12:28:23 -0400 Received: by mail-wr1-x429.google.com with SMTP id q13so21829932wrs.12 for ; Thu, 24 Oct 2019 09:28:23 -0700 (PDT) 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=+7fLMOIAWdycUDbs1+X1UPaZ+K02U2cR6zHlqPFssiE=; b=bJ4jbhhcGglf5BwDKbivsKqfc0quWBi+V9LS0554uicJCWxfDly0a8OazntBMO4cmn /kgqMbMKvg1Zi8a98Oo+BdVrRma7K3KcZ9vxCI55hY/s08jh8cdu7W1jJnPc7OnbSaWb JHzjPwrc3NXBTl3ReK6NWlmm1Qr4lcVInwg63kGOKs05qqVgKbIW07Xx4cXJkrTnHbQ2 nLNQctaVzMRiGannbZFJxvYcGTmgUa+LOit9VvSO0Bea+XAz0V1VU46y9+4Wv4HoCMlF R2i57uRYAMzT9h6FUwj1KJGwuPZtJTDBe1NSkICcc+uH0MhV/mJ6ZSClFnlyHu0DJVnh 1rBw== 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=+7fLMOIAWdycUDbs1+X1UPaZ+K02U2cR6zHlqPFssiE=; b=ilAo+jngDCiHkSbbUZ9c1M0KevdwbTa35PjbA8MHyX5Eu62yoc9b6ClyCqlwvmJLpj TLnviBqzsbRUkJ0XRGfXcl6F9dIxF+Hs+J/QOy+BIFMfMcCp07mIteM6zG4SmOgwr5Rz /yrEH5mJtC5MsOfEtTaLZwxwKzKeWLatzO8toYY+WBceiiLRPC9iwezI3uGI4Pl4PJSk CJVs/L/eEoNgzLpV1qrU/4pPu5NojIvan+32YqAt+a4hpYBiu1oZn5kp3FKlGpodcUPD 4Teo3Ljycj0qmgttrJhVVH/y5cJKdtrzVRsAhNyzPihtPvhlJHD/T6DxcHSqJZkbj1x1 s8xA== X-Gm-Message-State: APjAAAU1wAUngJyaLJFoECsIMIy5J/f5BSpUWl717gOpLh1va9zCz8SM hBq5wjzqKRQSaHzLkPAvOa0XIccMgf4= X-Google-Smtp-Source: APXvYqy6mDQlBFf7hRRa2psrJ1BFexuxvyUDGZOq3BktGJWPfY+2EW3pwwnPXmVH5m6n0mrEkP1LiA== X-Received: by 2002:a5d:5591:: with SMTP id i17mr4469584wrv.151.1571934502411; Thu, 24 Oct 2019 09:28:22 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id r27sm42606124wrc.55.2019.10.24.09.28.20 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Oct 2019 09:28:21 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 44/51] hw/misc/bcm2835_thermal: Add a dummy BCM2835 thermal sensor Date: Thu, 24 Oct 2019 17:27:17 +0100 Message-Id: <20191024162724.31675-45-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191024162724.31675-1-peter.maydell@linaro.org> References: <20191024162724.31675-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 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" From: Philippe Mathieu-Daudé We will soon implement the SYS_timer. This timer is used by Linux in the thermal subsystem, so once available, the subsystem will be enabled and poll the temperature sensors. We need to provide the minimum required to keep Linux booting. Add a dummy thermal sensor returning ~25°C based on: https://github.com/raspberrypi/linux/blob/rpi-5.3.y/drivers/thermal/broadcom/bcm2835_thermal.c Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Alistair Francis Message-id: 20191019234715.25750-2-f4bug@amsat.org Signed-off-by: Peter Maydell --- hw/misc/Makefile.objs | 1 + include/hw/misc/bcm2835_thermal.h | 27 ++++++ hw/misc/bcm2835_thermal.c | 135 ++++++++++++++++++++++++++++++ 3 files changed, 163 insertions(+) create mode 100644 include/hw/misc/bcm2835_thermal.h create mode 100644 hw/misc/bcm2835_thermal.c diff --git a/hw/misc/Makefile.objs b/hw/misc/Makefile.objs index a1506809660..c89f3816a52 100644 --- a/hw/misc/Makefile.objs +++ b/hw/misc/Makefile.objs @@ -53,6 +53,7 @@ common-obj-$(CONFIG_OMAP) += omap_tap.o common-obj-$(CONFIG_RASPI) += bcm2835_mbox.o common-obj-$(CONFIG_RASPI) += bcm2835_property.o common-obj-$(CONFIG_RASPI) += bcm2835_rng.o +common-obj-$(CONFIG_RASPI) += bcm2835_thermal.o common-obj-$(CONFIG_SLAVIO) += slavio_misc.o common-obj-$(CONFIG_ZYNQ) += zynq_slcr.o common-obj-$(CONFIG_ZYNQ) += zynq-xadc.o diff --git a/include/hw/misc/bcm2835_thermal.h b/include/hw/misc/bcm2835_thermal.h new file mode 100644 index 00000000000..c3651b27ec6 --- /dev/null +++ b/include/hw/misc/bcm2835_thermal.h @@ -0,0 +1,27 @@ +/* + * BCM2835 dummy thermal sensor + * + * Copyright (C) 2019 Philippe Mathieu-Daudé + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#ifndef HW_MISC_BCM2835_THERMAL_H +#define HW_MISC_BCM2835_THERMAL_H + +#include "hw/sysbus.h" + +#define TYPE_BCM2835_THERMAL "bcm2835-thermal" + +#define BCM2835_THERMAL(obj) \ + OBJECT_CHECK(Bcm2835ThermalState, (obj), TYPE_BCM2835_THERMAL) + +typedef struct { + /*< private >*/ + SysBusDevice parent_obj; + /*< public >*/ + MemoryRegion iomem; + uint32_t ctl; +} Bcm2835ThermalState; + +#endif diff --git a/hw/misc/bcm2835_thermal.c b/hw/misc/bcm2835_thermal.c new file mode 100644 index 00000000000..c6f3b1ad605 --- /dev/null +++ b/hw/misc/bcm2835_thermal.c @@ -0,0 +1,135 @@ +/* + * BCM2835 dummy thermal sensor + * + * Copyright (C) 2019 Philippe Mathieu-Daudé + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#include "qemu/osdep.h" +#include "qemu/log.h" +#include "qapi/error.h" +#include "hw/misc/bcm2835_thermal.h" +#include "hw/registerfields.h" +#include "migration/vmstate.h" + +REG32(CTL, 0) +FIELD(CTL, POWER_DOWN, 0, 1) +FIELD(CTL, RESET, 1, 1) +FIELD(CTL, BANDGAP_CTRL, 2, 3) +FIELD(CTL, INTERRUPT_ENABLE, 5, 1) +FIELD(CTL, DIRECT, 6, 1) +FIELD(CTL, INTERRUPT_CLEAR, 7, 1) +FIELD(CTL, HOLD, 8, 10) +FIELD(CTL, RESET_DELAY, 18, 8) +FIELD(CTL, REGULATOR_ENABLE, 26, 1) + +REG32(STAT, 4) +FIELD(STAT, DATA, 0, 10) +FIELD(STAT, VALID, 10, 1) +FIELD(STAT, INTERRUPT, 11, 1) + +#define THERMAL_OFFSET_C 412 +#define THERMAL_COEFF (-0.538f) + +static uint16_t bcm2835_thermal_temp2adc(int temp_C) +{ + return (temp_C - THERMAL_OFFSET_C) / THERMAL_COEFF; +} + +static uint64_t bcm2835_thermal_read(void *opaque, hwaddr addr, unsigned size) +{ + Bcm2835ThermalState *s = BCM2835_THERMAL(opaque); + uint32_t val = 0; + + switch (addr) { + case A_CTL: + val = s->ctl; + break; + case A_STAT: + /* Temperature is constantly 25°C. */ + val = FIELD_DP32(bcm2835_thermal_temp2adc(25), STAT, VALID, true); + break; + default: + /* MemoryRegionOps are aligned, so this can not happen. */ + g_assert_not_reached(); + } + return val; +} + +static void bcm2835_thermal_write(void *opaque, hwaddr addr, + uint64_t value, unsigned size) +{ + Bcm2835ThermalState *s = BCM2835_THERMAL(opaque); + + switch (addr) { + case A_CTL: + s->ctl = value; + break; + case A_STAT: + qemu_log_mask(LOG_GUEST_ERROR, "%s: write 0x%" PRIx64 + " to 0x%" HWADDR_PRIx "\n", + __func__, value, addr); + break; + default: + /* MemoryRegionOps are aligned, so this can not happen. */ + g_assert_not_reached(); + } +} + +static const MemoryRegionOps bcm2835_thermal_ops = { + .read = bcm2835_thermal_read, + .write = bcm2835_thermal_write, + .impl.max_access_size = 4, + .valid.min_access_size = 4, + .endianness = DEVICE_NATIVE_ENDIAN, +}; + +static void bcm2835_thermal_reset(DeviceState *dev) +{ + Bcm2835ThermalState *s = BCM2835_THERMAL(dev); + + s->ctl = 0; +} + +static void bcm2835_thermal_realize(DeviceState *dev, Error **errp) +{ + Bcm2835ThermalState *s = BCM2835_THERMAL(dev); + + memory_region_init_io(&s->iomem, OBJECT(s), &bcm2835_thermal_ops, + s, TYPE_BCM2835_THERMAL, 8); + sysbus_init_mmio(SYS_BUS_DEVICE(s), &s->iomem); +} + +static const VMStateDescription bcm2835_thermal_vmstate = { + .name = "bcm2835_thermal", + .version_id = 1, + .minimum_version_id = 1, + .fields = (VMStateField[]) { + VMSTATE_UINT32(ctl, Bcm2835ThermalState), + VMSTATE_END_OF_LIST() + } +}; + +static void bcm2835_thermal_class_init(ObjectClass *klass, void *data) +{ + DeviceClass *dc = DEVICE_CLASS(klass); + + dc->realize = bcm2835_thermal_realize; + dc->reset = bcm2835_thermal_reset; + dc->vmsd = &bcm2835_thermal_vmstate; +} + +static const TypeInfo bcm2835_thermal_info = { + .name = TYPE_BCM2835_THERMAL, + .parent = TYPE_SYS_BUS_DEVICE, + .instance_size = sizeof(Bcm2835ThermalState), + .class_init = bcm2835_thermal_class_init, +}; + +static void bcm2835_thermal_register_types(void) +{ + type_register_static(&bcm2835_thermal_info); +} + +type_init(bcm2835_thermal_register_types) From patchwork Thu Oct 24 16:27:18 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 11210481 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6AFE7139A for ; Thu, 24 Oct 2019 17:17:57 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 3F23F20659 for ; Thu, 24 Oct 2019 17:17:57 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="gh2UpAr1" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3F23F20659 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:48518 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNgkF-0001ZC-EP for patchwork-qemu-devel@patchwork.kernel.org; Thu, 24 Oct 2019 13:17:55 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58296) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNfyN-0008Ne-58 for qemu-devel@nongnu.org; Thu, 24 Oct 2019 12:28:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iNfyK-00015C-SC for qemu-devel@nongnu.org; Thu, 24 Oct 2019 12:28:26 -0400 Received: from mail-wr1-x434.google.com ([2a00:1450:4864:20::434]:44684) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iNfyK-00014x-M6 for qemu-devel@nongnu.org; Thu, 24 Oct 2019 12:28:24 -0400 Received: by mail-wr1-x434.google.com with SMTP id z11so3426695wro.11 for ; Thu, 24 Oct 2019 09:28:24 -0700 (PDT) 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=rFFq99KjNRPKwCumrUa38nTH8zpDsdg+udhpyP1ndZA=; b=gh2UpAr1dKcujn0ivGmq8cOE6z5VChPo4Q0f121SMOuchWjp1XxF13nJpA1ml4LEMz MY4kCmiUUaL8wlX6RUH3Y3gJEPTlDM7mQ9hGYM2eO5Rt2vn+ATX0asQogy5wZKFB7Poi 1I5VxTMg+MqEPEmU3UHGSehGWBH7k2ZAD5i5SEwEMIYUOA8MQk0nyVhb9Y4Ax7BhP1Vx mTKehyfkTC/7rGoJGgEhL1ZUMCMQ2BxPISzDi+pp+ATg0Srzytc9p6kXe3r3I3mY+7F1 ieb9iZKlJrQl4V1TsKkpKr1mZ6KGF5Kof/791g9L86Spo48k3ZyfxWWQF7xpB6+Ajg2X vr5w== 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=rFFq99KjNRPKwCumrUa38nTH8zpDsdg+udhpyP1ndZA=; b=XW+natUmbPzYoizH3E9cGmsdNF8dpjhtFe2ju0HGR+ErIzMdaAFxmcyVaJZhSQQ3k/ 3s5LMbXr/jkMyXFG31JeSRqWyF72jUPLiwrr1qHIF28j72LuF9kRMpwzPDWsIZ/Qo4Xg OxlhIW/5tFoWgecy4B4OnAXxpRL0v2YY+FfrycGLojYeWK/Cz6AS3pRcBTFHuwTDx8bj EJl+JdUO3Zo6ufGTIER/tJmWhX4OKAgzD31dN7hMUOIKL/xWBlBfACtR5dRAfBk1dCT/ HZ3fh5wQJUs3lAykBtHRN6tYoCvm5PR/ucmuqTpXAYfTHiGDIPDmgYUCRhCe/TlfN9+1 u1bg== X-Gm-Message-State: APjAAAWr9ra35A/6af9LQuh4eT8y73iwbCjQzMerqeNjUCPDkQFj578m ZEmsGj2hMG6sLBPf46PgPQYrNVYFL8M= X-Google-Smtp-Source: APXvYqz3fjWED6wXjAzRNtRQnQpyeYa62gT4qVkvaBezR59gGgPrulRiriIpjVql5k31As1LiDfcVw== X-Received: by 2002:a5d:6a03:: with SMTP id m3mr4390417wru.90.1571934503453; Thu, 24 Oct 2019 09:28:23 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id r27sm42606124wrc.55.2019.10.24.09.28.22 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Oct 2019 09:28:22 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 45/51] hw/arm/bcm2835_peripherals: Use the thermal sensor block Date: Thu, 24 Oct 2019 17:27:18 +0100 Message-Id: <20191024162724.31675-46-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191024162724.31675-1-peter.maydell@linaro.org> References: <20191024162724.31675-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 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" From: Philippe Mathieu-Daudé Map the thermal sensor in the BCM2835 block. Reviewed-by: Alistair Francis Signed-off-by: Philippe Mathieu-Daudé Message-id: 20191019234715.25750-3-f4bug@amsat.org Signed-off-by: Peter Maydell --- include/hw/arm/bcm2835_peripherals.h | 2 ++ include/hw/arm/raspi_platform.h | 1 + hw/arm/bcm2835_peripherals.c | 13 +++++++++++++ 3 files changed, 16 insertions(+) diff --git a/include/hw/arm/bcm2835_peripherals.h b/include/hw/arm/bcm2835_peripherals.h index 62a4c7b559d..be7ad9b4991 100644 --- a/include/hw/arm/bcm2835_peripherals.h +++ b/include/hw/arm/bcm2835_peripherals.h @@ -20,6 +20,7 @@ #include "hw/misc/bcm2835_property.h" #include "hw/misc/bcm2835_rng.h" #include "hw/misc/bcm2835_mbox.h" +#include "hw/misc/bcm2835_thermal.h" #include "hw/sd/sdhci.h" #include "hw/sd/bcm2835_sdhost.h" #include "hw/gpio/bcm2835_gpio.h" @@ -53,6 +54,7 @@ typedef struct BCM2835PeripheralState { SDHCIState sdhci; BCM2835SDHostState sdhost; BCM2835GpioState gpio; + Bcm2835ThermalState thermal; UnimplementedDeviceState i2s; UnimplementedDeviceState spi[1]; UnimplementedDeviceState i2c[3]; diff --git a/include/hw/arm/raspi_platform.h b/include/hw/arm/raspi_platform.h index cdcbca943fb..61b04a1bd4a 100644 --- a/include/hw/arm/raspi_platform.h +++ b/include/hw/arm/raspi_platform.h @@ -48,6 +48,7 @@ #define SPI0_OFFSET 0x204000 #define BSC0_OFFSET 0x205000 /* BSC0 I2C/TWI */ #define OTP_OFFSET 0x20f000 +#define THERMAL_OFFSET 0x212000 #define BSC_SL_OFFSET 0x214000 /* SPI slave */ #define AUX_OFFSET 0x215000 /* AUX: UART1/SPI1/SPI2 */ #define EMMC1_OFFSET 0x300000 diff --git a/hw/arm/bcm2835_peripherals.c b/hw/arm/bcm2835_peripherals.c index fdcf616c56a..70bf927a025 100644 --- a/hw/arm/bcm2835_peripherals.c +++ b/hw/arm/bcm2835_peripherals.c @@ -111,6 +111,10 @@ static void bcm2835_peripherals_init(Object *obj) object_property_add_const_link(OBJECT(&s->dma), "dma-mr", OBJECT(&s->gpu_bus_mr), &error_abort); + /* Thermal */ + sysbus_init_child_obj(obj, "thermal", &s->thermal, sizeof(s->thermal), + TYPE_BCM2835_THERMAL); + /* GPIO */ sysbus_init_child_obj(obj, "gpio", &s->gpio, sizeof(s->gpio), TYPE_BCM2835_GPIO); @@ -321,6 +325,15 @@ static void bcm2835_peripherals_realize(DeviceState *dev, Error **errp) INTERRUPT_DMA0 + n)); } + /* THERMAL */ + object_property_set_bool(OBJECT(&s->thermal), true, "realized", &err); + if (err) { + error_propagate(errp, err); + return; + } + memory_region_add_subregion(&s->peri_mr, THERMAL_OFFSET, + sysbus_mmio_get_region(SYS_BUS_DEVICE(&s->thermal), 0)); + /* GPIO */ object_property_set_bool(OBJECT(&s->gpio), true, "realized", &err); if (err) { From patchwork Thu Oct 24 16:27: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: 11210535 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5A11B139A for ; Thu, 24 Oct 2019 17:25:13 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 2E8AD205F4 for ; Thu, 24 Oct 2019 17:25:13 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="ZdOgtxtv" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2E8AD205F4 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:48664 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNgrI-0003C2-3h for patchwork-qemu-devel@patchwork.kernel.org; Thu, 24 Oct 2019 13:25:12 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58325) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNfyP-0008Tc-6D for qemu-devel@nongnu.org; Thu, 24 Oct 2019 12:28:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iNfyN-00016O-58 for qemu-devel@nongnu.org; Thu, 24 Oct 2019 12:28:29 -0400 Received: from mail-wr1-x42d.google.com ([2a00:1450:4864:20::42d]:44678) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iNfyM-00015w-UY for qemu-devel@nongnu.org; Thu, 24 Oct 2019 12:28:27 -0400 Received: by mail-wr1-x42d.google.com with SMTP id z11so3426845wro.11 for ; Thu, 24 Oct 2019 09:28:26 -0700 (PDT) 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=vzBTgyNx8Q8kNnyl3gqBcooBFcldGb6ykyZpy3nNnJw=; b=ZdOgtxtv3jAqST3lumMDv45pApUp8tB4HQv8KafsqwK89KgERk35wv7DkRTHj5Nf8r HyacBEeu9r7nKvcOex/6DSikjL6K8XQBTl8GIwDhhQFrSh3zHrwHlsE6SR5KxTEFBBdj mbeOp+PusLIFS5Wa30HCW7BQ94y6wX0cQLZzb90vBILu3gVj8qN5MgULBg2qnmVFu/Pi VE4gmNZBiCa+v52yFijdtMFm1pqVTajKzKWn2YjhISWS29I0lVP0pgCP+lW2D+9AIKg8 2pY91TserMHUguIpLVmKomBswt0L6JBVsJk5IOsaIE00Zst8NL6QEfNeJ+4n+eb+zNWz c6vw== 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=vzBTgyNx8Q8kNnyl3gqBcooBFcldGb6ykyZpy3nNnJw=; b=reSJiFus1K0HpQlgcjmPPeNjieIQd7eS/ScaMIqvAHg+sgyCkxpaVowKoi3JnWUPzp xV+trkWkgtsj8npqDw4o126WFgKFOh9XxwB4E7xj1dzib0D3InPFBVhZLj48O5ClWhxi F5RSM/zNmkUFno/IJSrNnBaBIT3jd1swELH2VoGqbF6Raj9JDUE9F1pp9M24bLi3pceZ X0OH7H6pFS+sCBJy/69+FVDg2dv9hwUqJeJsPAPQl7pEMRoHS7TfPJIBUoUUwwuRwlvF 2VREkdvdLYuBpCcYUTSmH/HCLUR6xRJWApdagW9T0ECzUfqxautc/6xSdj91AlTdyVSY im/w== X-Gm-Message-State: APjAAAVl8b7lHb1OuBRCvjI2uDOQKEq0l/fq1i5WrcqNAFjKJ9ikO3Vf G4TBJDNFmlB/l3rdTTSTHhhqXjTgs2U= X-Google-Smtp-Source: APXvYqzmuliKA2Z5sbHlqe/Vs+cFokL40PNv/HImGjdW5grdSh4o88oKo8/RX8sa0tp3MqJDemBknA== X-Received: by 2002:a05:6000:4f:: with SMTP id k15mr4417035wrx.137.1571934505498; Thu, 24 Oct 2019 09:28:25 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id r27sm42606124wrc.55.2019.10.24.09.28.23 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Oct 2019 09:28:24 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 46/51] hw/timer/bcm2835: Add the BCM2835 SYS_timer Date: Thu, 24 Oct 2019 17:27:19 +0100 Message-Id: <20191024162724.31675-47-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191024162724.31675-1-peter.maydell@linaro.org> References: <20191024162724.31675-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::42d X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" From: Philippe Mathieu-Daudé Add the 64-bit free running timer. Do not model the COMPARE register (no IRQ generated). This timer is used by Linux kernel and recently U-Boot: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/clocksource/bcm2835_timer.c?h=v3.7 https://github.com/u-boot/u-boot/blob/v2019.07/include/configs/rpi.h#L19 Datasheet used: https://www.raspberrypi.org/app/uploads/2012/02/BCM2835-ARM-Peripherals.pdf Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Alistair Francis Message-id: 20191019234715.25750-4-f4bug@amsat.org [PMM: squashed in switch to using memset in reset] Signed-off-by: Peter Maydell --- hw/timer/Makefile.objs | 1 + include/hw/timer/bcm2835_systmr.h | 33 ++++++ hw/timer/bcm2835_systmr.c | 163 ++++++++++++++++++++++++++++++ hw/timer/trace-events | 5 + 4 files changed, 202 insertions(+) create mode 100644 include/hw/timer/bcm2835_systmr.h create mode 100644 hw/timer/bcm2835_systmr.c diff --git a/hw/timer/Makefile.objs b/hw/timer/Makefile.objs index 123d92c9692..696cda59052 100644 --- a/hw/timer/Makefile.objs +++ b/hw/timer/Makefile.objs @@ -47,3 +47,4 @@ common-obj-$(CONFIG_SUN4V_RTC) += sun4v-rtc.o common-obj-$(CONFIG_CMSDK_APB_TIMER) += cmsdk-apb-timer.o common-obj-$(CONFIG_CMSDK_APB_DUALTIMER) += cmsdk-apb-dualtimer.o common-obj-$(CONFIG_MSF2) += mss-timer.o +common-obj-$(CONFIG_RASPI) += bcm2835_systmr.o diff --git a/include/hw/timer/bcm2835_systmr.h b/include/hw/timer/bcm2835_systmr.h new file mode 100644 index 00000000000..c0bc5c81270 --- /dev/null +++ b/include/hw/timer/bcm2835_systmr.h @@ -0,0 +1,33 @@ +/* + * BCM2835 SYS timer emulation + * + * Copyright (c) 2019 Philippe Mathieu-Daudé + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#ifndef BCM2835_SYSTIMER_H +#define BCM2835_SYSTIMER_H + +#include "hw/sysbus.h" +#include "hw/irq.h" + +#define TYPE_BCM2835_SYSTIMER "bcm2835-sys-timer" +#define BCM2835_SYSTIMER(obj) \ + OBJECT_CHECK(BCM2835SystemTimerState, (obj), TYPE_BCM2835_SYSTIMER) + +typedef struct { + /*< private >*/ + SysBusDevice parent_obj; + + /*< public >*/ + MemoryRegion iomem; + qemu_irq irq; + + struct { + uint32_t status; + uint32_t compare[4]; + } reg; +} BCM2835SystemTimerState; + +#endif diff --git a/hw/timer/bcm2835_systmr.c b/hw/timer/bcm2835_systmr.c new file mode 100644 index 00000000000..3387a6214a2 --- /dev/null +++ b/hw/timer/bcm2835_systmr.c @@ -0,0 +1,163 @@ +/* + * BCM2835 SYS timer emulation + * + * Copyright (C) 2019 Philippe Mathieu-Daudé + * + * SPDX-License-Identifier: GPL-2.0-or-later + * + * Datasheet: BCM2835 ARM Peripherals (C6357-M-1398) + * https://www.raspberrypi.org/app/uploads/2012/02/BCM2835-ARM-Peripherals.pdf + * + * Only the free running 64-bit counter is implemented. + * The 4 COMPARE registers and the interruption are not implemented. + */ + +#include "qemu/osdep.h" +#include "qemu/log.h" +#include "qemu/timer.h" +#include "hw/timer/bcm2835_systmr.h" +#include "hw/registerfields.h" +#include "migration/vmstate.h" +#include "trace.h" + +REG32(CTRL_STATUS, 0x00) +REG32(COUNTER_LOW, 0x04) +REG32(COUNTER_HIGH, 0x08) +REG32(COMPARE0, 0x0c) +REG32(COMPARE1, 0x10) +REG32(COMPARE2, 0x14) +REG32(COMPARE3, 0x18) + +static void bcm2835_systmr_update_irq(BCM2835SystemTimerState *s) +{ + bool enable = !!s->reg.status; + + trace_bcm2835_systmr_irq(enable); + qemu_set_irq(s->irq, enable); +} + +static void bcm2835_systmr_update_compare(BCM2835SystemTimerState *s, + unsigned timer_index) +{ + /* TODO fow now, since neither Linux nor U-boot use these timers. */ + qemu_log_mask(LOG_UNIMP, "COMPARE register %u not implemented\n", + timer_index); +} + +static uint64_t bcm2835_systmr_read(void *opaque, hwaddr offset, + unsigned size) +{ + BCM2835SystemTimerState *s = BCM2835_SYSTIMER(opaque); + uint64_t r = 0; + + switch (offset) { + case A_CTRL_STATUS: + r = s->reg.status; + break; + case A_COMPARE0 ... A_COMPARE3: + r = s->reg.compare[(offset - A_COMPARE0) >> 2]; + break; + case A_COUNTER_LOW: + case A_COUNTER_HIGH: + /* Free running counter at 1MHz */ + r = qemu_clock_get_us(QEMU_CLOCK_VIRTUAL); + r >>= 8 * (offset - A_COUNTER_LOW); + r &= UINT32_MAX; + break; + default: + qemu_log_mask(LOG_GUEST_ERROR, "%s: bad offset 0x%" HWADDR_PRIx "\n", + __func__, offset); + break; + } + trace_bcm2835_systmr_read(offset, r); + + return r; +} + +static void bcm2835_systmr_write(void *opaque, hwaddr offset, + uint64_t value, unsigned size) +{ + BCM2835SystemTimerState *s = BCM2835_SYSTIMER(opaque); + + trace_bcm2835_systmr_write(offset, value); + switch (offset) { + case A_CTRL_STATUS: + s->reg.status &= ~value; /* Ack */ + bcm2835_systmr_update_irq(s); + break; + case A_COMPARE0 ... A_COMPARE3: + s->reg.compare[(offset - A_COMPARE0) >> 2] = value; + bcm2835_systmr_update_compare(s, (offset - A_COMPARE0) >> 2); + break; + case A_COUNTER_LOW: + case A_COUNTER_HIGH: + qemu_log_mask(LOG_GUEST_ERROR, "%s: read-only ofs 0x%" HWADDR_PRIx "\n", + __func__, offset); + break; + default: + qemu_log_mask(LOG_GUEST_ERROR, "%s: bad offset 0x%" HWADDR_PRIx "\n", + __func__, offset); + break; + } +} + +static const MemoryRegionOps bcm2835_systmr_ops = { + .read = bcm2835_systmr_read, + .write = bcm2835_systmr_write, + .endianness = DEVICE_LITTLE_ENDIAN, + .impl = { + .min_access_size = 4, + .max_access_size = 4, + }, +}; + +static void bcm2835_systmr_reset(DeviceState *dev) +{ + BCM2835SystemTimerState *s = BCM2835_SYSTIMER(dev); + + memset(&s->reg, 0, sizeof(s->reg)); +} + +static void bcm2835_systmr_realize(DeviceState *dev, Error **errp) +{ + BCM2835SystemTimerState *s = BCM2835_SYSTIMER(dev); + + memory_region_init_io(&s->iomem, OBJECT(dev), &bcm2835_systmr_ops, + s, "bcm2835-sys-timer", 0x20); + sysbus_init_mmio(SYS_BUS_DEVICE(dev), &s->iomem); + sysbus_init_irq(SYS_BUS_DEVICE(dev), &s->irq); +} + +static const VMStateDescription bcm2835_systmr_vmstate = { + .name = "bcm2835_sys_timer", + .version_id = 1, + .minimum_version_id = 1, + .fields = (VMStateField[]) { + VMSTATE_UINT32(reg.status, BCM2835SystemTimerState), + VMSTATE_UINT32_ARRAY(reg.compare, BCM2835SystemTimerState, 4), + VMSTATE_END_OF_LIST() + } +}; + +static void bcm2835_systmr_class_init(ObjectClass *klass, void *data) +{ + DeviceClass *dc = DEVICE_CLASS(klass); + + dc->realize = bcm2835_systmr_realize; + dc->reset = bcm2835_systmr_reset; + dc->vmsd = &bcm2835_systmr_vmstate; +} + +static const TypeInfo bcm2835_systmr_info = { + .name = TYPE_BCM2835_SYSTIMER, + .parent = TYPE_SYS_BUS_DEVICE, + .instance_size = sizeof(BCM2835SystemTimerState), + .class_init = bcm2835_systmr_class_init, +}; + +static void bcm2835_systmr_register_types(void) +{ + type_register_static(&bcm2835_systmr_info); +} + +type_init(bcm2835_systmr_register_types); diff --git a/hw/timer/trace-events b/hw/timer/trace-events index db02a9142cd..0aa399ac69a 100644 --- a/hw/timer/trace-events +++ b/hw/timer/trace-events @@ -87,3 +87,8 @@ 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" + +# bcm2835_systmr.c +bcm2835_systmr_irq(bool enable) "timer irq state %u" +bcm2835_systmr_read(uint64_t offset, uint64_t data) "timer read: offset 0x%" PRIx64 " data 0x%" PRIx64 +bcm2835_systmr_write(uint64_t offset, uint64_t data) "timer write: offset 0x%" PRIx64 " data 0x%" PRIx64 From patchwork Thu Oct 24 16:27:20 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 11210517 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9CD6713B1 for ; Thu, 24 Oct 2019 17:22:22 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 7263B205F4 for ; Thu, 24 Oct 2019 17:22:22 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="iObXXY1Q" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7263B205F4 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:48594 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNgoX-0004e9-5P for patchwork-qemu-devel@patchwork.kernel.org; Thu, 24 Oct 2019 13:22:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58332) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNfyP-0008UX-HA for qemu-devel@nongnu.org; Thu, 24 Oct 2019 12:28:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iNfyO-00016q-9a for qemu-devel@nongnu.org; Thu, 24 Oct 2019 12:28:29 -0400 Received: from mail-wm1-x341.google.com ([2a00:1450:4864:20::341]:55226) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iNfyO-00016V-2t for qemu-devel@nongnu.org; Thu, 24 Oct 2019 12:28:28 -0400 Received: by mail-wm1-x341.google.com with SMTP id g7so3537789wmk.4 for ; Thu, 24 Oct 2019 09:28:27 -0700 (PDT) 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=c6aABKpXMCHWTjg1I/aM1uM5Hh9/GIS1D4WV2556Mg4=; b=iObXXY1Qjasb8l9kgr5weofW45cXjcwtCFMDzcVvAU3uU7j9sT5YtD6JwCU81t++Ad wwULvHdfkdTUbPzBYolGqB8t6ESOuI2mq9JfjAWrXKEn7/T4C/oDl7F7heEWzdnT4s9V nVSCGdLHnjoaym7YYKyUHK0lACk/R9JavA3MOjA6Ve0E4aZJELoi4W77SKpmw7wuyV9a C1QPwpPZs2LfwYcAQ6ry+2cGBk0pxKmS3lqalO0bBWdgNdJhVbPmR76DSru1XSVO6Wmc Z33Nb7hP4o+i7ArakcGuaujvaKwb9LP4texfGD+XILuyguttRHbfjnwXz4f5C7j+7xHc T36g== 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=c6aABKpXMCHWTjg1I/aM1uM5Hh9/GIS1D4WV2556Mg4=; b=oddx0vnm7hwCaC/rXM6BBUe76hexiNzAFHziVcj1G580xbZlYyfYLXP6STx+/fPVy5 sDKYAPAHAJT1XL9DwEFpiGPT8RVaeYUJSDKZupLKE6q5ju+q2Xft3FTKYAR49kJqGY7w QAOkf5l2Aumxcd+P0t2wuzfZ2vwt9VinL3AympS1k79lRuij3fh6vlKXZTqCSASR7o9e 8leXD+BX4n2PYQ+lqljv2/+TWm6o6Qrl2uPYEWRpFsJMLRwaaGQ6Z2JrFyJvjbRs63k9 R4vmC02mDYQGoshp4RDz0ue2s+gUb3Rh2Qla4iabyFcML8VszrQj+yzc6wdxi9lucs/u G6zg== X-Gm-Message-State: APjAAAVw/H1wvt9MmzEXk95JyCMq2jdPhGuOoYtQAKfPb0xIxdo1YH7J puaTWIQZTrCeTI4H3m/fYBkw/6MsSJ8= X-Google-Smtp-Source: APXvYqwp6Mliq7OTsooiSgNJ+7lX+B8x/qXvzRAkI/UQ4psqBISTCzzBe258vhsNctHz2jZqiXAb4w== X-Received: by 2002:a1c:2407:: with SMTP id k7mr5324814wmk.99.1571934506809; Thu, 24 Oct 2019 09:28:26 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id r27sm42606124wrc.55.2019.10.24.09.28.25 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Oct 2019 09:28:25 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 47/51] hw/arm/bcm2835_peripherals: Use the SYS_timer Date: Thu, 24 Oct 2019 17:27:20 +0100 Message-Id: <20191024162724.31675-48-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191024162724.31675-1-peter.maydell@linaro.org> References: <20191024162724.31675-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::341 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" From: Philippe Mathieu-Daudé Connect the recently added SYS_timer. Now U-Boot does not hang anymore polling a free running counter stuck at 0. This timer is also used by the Linux kernel thermal subsystem. Reviewed-by: Alistair Francis Signed-off-by: Philippe Mathieu-Daudé Message-id: 20191019234715.25750-5-f4bug@amsat.org Signed-off-by: Peter Maydell --- include/hw/arm/bcm2835_peripherals.h | 3 ++- hw/arm/bcm2835_peripherals.c | 17 ++++++++++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/include/hw/arm/bcm2835_peripherals.h b/include/hw/arm/bcm2835_peripherals.h index be7ad9b4991..7859281e11b 100644 --- a/include/hw/arm/bcm2835_peripherals.h +++ b/include/hw/arm/bcm2835_peripherals.h @@ -24,6 +24,7 @@ #include "hw/sd/sdhci.h" #include "hw/sd/bcm2835_sdhost.h" #include "hw/gpio/bcm2835_gpio.h" +#include "hw/timer/bcm2835_systmr.h" #include "hw/misc/unimp.h" #define TYPE_BCM2835_PERIPHERALS "bcm2835-peripherals" @@ -39,7 +40,7 @@ typedef struct BCM2835PeripheralState { MemoryRegion ram_alias[4]; qemu_irq irq, fiq; - UnimplementedDeviceState systmr; + BCM2835SystemTimerState systmr; UnimplementedDeviceState armtmr; UnimplementedDeviceState cprman; UnimplementedDeviceState a2w; diff --git a/hw/arm/bcm2835_peripherals.c b/hw/arm/bcm2835_peripherals.c index 70bf927a025..17207ae07e3 100644 --- a/hw/arm/bcm2835_peripherals.c +++ b/hw/arm/bcm2835_peripherals.c @@ -58,6 +58,10 @@ static void bcm2835_peripherals_init(Object *obj) /* Interrupt Controller */ sysbus_init_child_obj(obj, "ic", &s->ic, sizeof(s->ic), TYPE_BCM2835_IC); + /* SYS Timer */ + sysbus_init_child_obj(obj, "systimer", &s->systmr, sizeof(s->systmr), + TYPE_BCM2835_SYSTIMER); + /* UART0 */ sysbus_init_child_obj(obj, "uart0", &s->uart0, sizeof(s->uart0), TYPE_PL011); @@ -171,6 +175,18 @@ static void bcm2835_peripherals_realize(DeviceState *dev, Error **errp) sysbus_mmio_get_region(SYS_BUS_DEVICE(&s->ic), 0)); sysbus_pass_irq(SYS_BUS_DEVICE(s), SYS_BUS_DEVICE(&s->ic)); + /* Sys Timer */ + object_property_set_bool(OBJECT(&s->systmr), true, "realized", &err); + if (err) { + error_propagate(errp, err); + return; + } + memory_region_add_subregion(&s->peri_mr, ST_OFFSET, + sysbus_mmio_get_region(SYS_BUS_DEVICE(&s->systmr), 0)); + sysbus_connect_irq(SYS_BUS_DEVICE(&s->systmr), 0, + qdev_get_gpio_in_named(DEVICE(&s->ic), BCM2835_IC_ARM_IRQ, + INTERRUPT_ARM_TIMER)); + /* UART0 */ qdev_prop_set_chr(DEVICE(&s->uart0), "chardev", serial_hd(0)); object_property_set_bool(OBJECT(&s->uart0), true, "realized", &err); @@ -352,7 +368,6 @@ static void bcm2835_peripherals_realize(DeviceState *dev, Error **errp) } create_unimp(s, &s->armtmr, "bcm2835-sp804", ARMCTRL_TIMER0_1_OFFSET, 0x40); - create_unimp(s, &s->systmr, "bcm2835-systimer", ST_OFFSET, 0x20); create_unimp(s, &s->cprman, "bcm2835-cprman", CPRMAN_OFFSET, 0x1000); create_unimp(s, &s->a2w, "bcm2835-a2w", A2W_OFFSET, 0x1000); create_unimp(s, &s->i2s, "bcm2835-i2s", I2S_OFFSET, 0x100); From patchwork Thu Oct 24 16:27:21 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 11210541 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1CC7213B1 for ; Thu, 24 Oct 2019 17:27:38 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E700920659 for ; Thu, 24 Oct 2019 17:27:37 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="fYmn6HIB" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E700920659 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:48728 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNgtc-0007kE-FS for patchwork-qemu-devel@patchwork.kernel.org; Thu, 24 Oct 2019 13:27:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58347) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNfyQ-0008VX-Lv for qemu-devel@nongnu.org; Thu, 24 Oct 2019 12:28:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iNfyP-00017D-F3 for qemu-devel@nongnu.org; Thu, 24 Oct 2019 12:28:30 -0400 Received: from mail-wr1-x443.google.com ([2a00:1450:4864:20::443]:41363) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iNfyP-00016u-86 for qemu-devel@nongnu.org; Thu, 24 Oct 2019 12:28:29 -0400 Received: by mail-wr1-x443.google.com with SMTP id p4so26810092wrm.8 for ; Thu, 24 Oct 2019 09:28:29 -0700 (PDT) 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=PQl3KRLLMTqQVuIeb30pOMqlU1Q+h9n4TjUf1vQdg9c=; b=fYmn6HIBA7dRRro2xV4cZaHTLEOMMlxD0C0n7MgBh8Vj1ozFkfrm9+omC7HNvko6Ct fV9IKXMADK3BDdQhFS4hMaT+llFrDCF/zDtgxCCmjknjQ14g3DNh+oZUJ682o1yyeU3r B4iuZX6uTS+e+GteP3JlB+TexOrNIShgAvUSSs3sgqXQMd8J/niSFi2Sz/N1Rzbysg7C HmWROBDlZzptg+/0IjlZ+MsdbgD8x3vklM9yDBgLhR7vgkLqJsE5WRbq4C3Rgo0sGMHu ChZj6bIFOchgFhfD2K0INRgZAo6gY0NGF6kjDwgxv3Mr71lS8OalKecmKkIncRssAkFn H0xw== 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=PQl3KRLLMTqQVuIeb30pOMqlU1Q+h9n4TjUf1vQdg9c=; b=kYWsVQjvx1afr6a0FXtSPS+j/WzV3LW6sVPm4P3tmSBn+Tyd6YoY1e39s3VQu6iNbM vb8Ik4tTbxxv4ZB3auAhPXF/KXrXSiTE5qkajUbzgM+90FvoyKbNV8i6hXZcg7pgYRGE DY2m+rhjKqReiCa8KL8ZGqf5OzYEUY4McM6wW8CVx7bIFwKDVgXeAtY26Wun0HDkc/9t rF6XOcK8wtcpXYYlaLH1bDBpJsIwLfQ9AQPPXTWIzTs5eazahoh1F5IgvuAA91IeaL6j D9XytH0BOiFpinurSERwV2bsesKw9Cxi09ONUKkSi3dZWR0kLQyEScYSxh4sRP6bLEU4 lU0A== X-Gm-Message-State: APjAAAUhI9NEhbdMUPNfvodjh/P5cbb/+4dX5u0iwD6tNbFHXOBiJA50 QSlLg5+Yrg6vTOGky3EXdnubmXhjFbA= X-Google-Smtp-Source: APXvYqwG0L67Q+K133w0CcBAr74CSaiB6KGmJqCtjYNfyH/b5jUG4geUNXsFeBR4hoAa7JjGNjBNUA== X-Received: by 2002:adf:e850:: with SMTP id d16mr4459575wrn.251.1571934508049; Thu, 24 Oct 2019 09:28:28 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id r27sm42606124wrc.55.2019.10.24.09.28.26 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Oct 2019 09:28:27 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 48/51] hw/arm/bcm2836: Make the SoC code modular Date: Thu, 24 Oct 2019 17:27:21 +0100 Message-Id: <20191024162724.31675-49-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191024162724.31675-1-peter.maydell@linaro.org> References: <20191024162724.31675-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 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" From: Philippe Mathieu-Daudé This file creates the BCM2836/BCM2837 blocks. The biggest differences with the BCM2838 we are going to add, are the base addresses of the interrupt controller and the peripherals. Add these addresses in the BCM283XInfo structure to make this block more modular. Remove the MCORE_OFFSET offset as it is not useful and rather confusing. Reviewed-by: Esteban Bosse Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Alistair Francis Message-id: 20191019234715.25750-6-f4bug@amsat.org Signed-off-by: Peter Maydell --- hw/arm/bcm2836.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/hw/arm/bcm2836.c b/hw/arm/bcm2836.c index 723aef6bf51..019e67b9068 100644 --- a/hw/arm/bcm2836.c +++ b/hw/arm/bcm2836.c @@ -16,15 +16,11 @@ #include "hw/arm/raspi_platform.h" #include "hw/sysbus.h" -/* Peripheral base address seen by the CPU */ -#define BCM2836_PERI_BASE 0x3F000000 - -/* "QA7" (Pi2) interrupt controller and mailboxes etc. */ -#define BCM2836_CONTROL_BASE 0x40000000 - struct BCM283XInfo { const char *name; const char *cpu_type; + hwaddr peri_base; /* Peripheral base address seen by the CPU */ + hwaddr ctrl_base; /* Interrupt controller and mailboxes etc. */ int clusterid; }; @@ -32,12 +28,16 @@ static const BCM283XInfo bcm283x_socs[] = { { .name = TYPE_BCM2836, .cpu_type = ARM_CPU_TYPE_NAME("cortex-a7"), + .peri_base = 0x3f000000, + .ctrl_base = 0x40000000, .clusterid = 0xf, }, #ifdef TARGET_AARCH64 { .name = TYPE_BCM2837, .cpu_type = ARM_CPU_TYPE_NAME("cortex-a53"), + .peri_base = 0x3f000000, + .ctrl_base = 0x40000000, .clusterid = 0x0, }, #endif @@ -104,7 +104,7 @@ static void bcm2836_realize(DeviceState *dev, Error **errp) } sysbus_mmio_map_overlap(SYS_BUS_DEVICE(&s->peripherals), 0, - BCM2836_PERI_BASE, 1); + info->peri_base, 1); /* bcm2836 interrupt controller (and mailboxes, etc.) */ object_property_set_bool(OBJECT(&s->control), true, "realized", &err); @@ -113,7 +113,7 @@ static void bcm2836_realize(DeviceState *dev, Error **errp) return; } - sysbus_mmio_map(SYS_BUS_DEVICE(&s->control), 0, BCM2836_CONTROL_BASE); + sysbus_mmio_map(SYS_BUS_DEVICE(&s->control), 0, info->ctrl_base); sysbus_connect_irq(SYS_BUS_DEVICE(&s->peripherals), 0, qdev_get_gpio_in_named(DEVICE(&s->control), "gpu-irq", 0)); @@ -126,7 +126,7 @@ static void bcm2836_realize(DeviceState *dev, Error **errp) /* set periphbase/CBAR value for CPU-local registers */ object_property_set_int(OBJECT(&s->cpus[n]), - BCM2836_PERI_BASE + MSYNC_OFFSET, + info->peri_base, "reset-cbar", &err); if (err) { error_propagate(errp, err); From patchwork Thu Oct 24 16:27:22 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 11210555 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id AB8FC112C for ; Thu, 24 Oct 2019 17:31:02 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 81CF9205C9 for ; Thu, 24 Oct 2019 17:31:02 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="M40LfjeE" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 81CF9205C9 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:48792 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNgwu-0000WR-MV for patchwork-qemu-devel@patchwork.kernel.org; Thu, 24 Oct 2019 13:31:00 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58365) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNfyT-000089-28 for qemu-devel@nongnu.org; Thu, 24 Oct 2019 12:28:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iNfyR-00017v-OS for qemu-devel@nongnu.org; Thu, 24 Oct 2019 12:28:32 -0400 Received: from mail-wm1-x32d.google.com ([2a00:1450:4864:20::32d]:52278) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iNfyR-00017K-IG for qemu-devel@nongnu.org; Thu, 24 Oct 2019 12:28:31 -0400 Received: by mail-wm1-x32d.google.com with SMTP id p21so2101721wmg.2 for ; Thu, 24 Oct 2019 09:28:31 -0700 (PDT) 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=DYAw+JFUSShxadh7hIyLKy0VSgftJwrYe33MmrE6aTY=; b=M40LfjeEYv2ob6JYDv4HpJ/kowyBFQpxUwA4Yh4uXOzaII8oNUBzU5WfS2JX2FBqOd qzdtQmxkZ2oZtnhnCxx3ULaLKttk1VYBBZVJ5oTh1tX+hLKL1R/37wp6ceFntQ708XSK gpGUKTxYfea32s051YKpoVHDUhQl/lFUNB/0EZy4tosgb5SqZC9RNzD92n4OOKd6ST9Q nEZK/8dU9lM8J5Qsfoshe4ZysBrFqwH60a6FdGsTQNUv9IPPBLjNBGZkGaVStX6lGZzn VUb2Bi+rBASHieUXli2JxqHHlpt3Rh9QAPth1Ci6zh6WSPXCT/NqWnzkHjjL4m9ZtwYD yJZA== 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=DYAw+JFUSShxadh7hIyLKy0VSgftJwrYe33MmrE6aTY=; b=d5eklWd9rI8yj5lKFudvMQq6AbZS2dml9K2fd6gKioOzLosyPGpwPCcj5YOLZ0Qm3X i8nmyk4TMwFoZ6MiUmYPxwbplNWWGIinGR/LFYyl5G36YBfShQCfH5qPhOyGrvKuPpWT KS7radd0UXZ0p0Y37XmcCW72214dgO9l6zv4Mv9/1A9uBd0YTrZZeQ570ncCIxIUzqQA KbRghGCwwZTrCyM0uCBAhGRK3yyL0acQ0BpVM9sUWh5mWmk6+9qsqjqF+NvHxgF642Fp zRoROKtAlZ+RsR9NvXPeC7C/adYekJU2vjXkkGnDPlqO5mRZfbf6vdKtEWsbHklCf9HM NXMQ== X-Gm-Message-State: APjAAAVXMM98ohEaBqnZd7P4banI3U0rENNSerlXTldcl3GOuUg9ydlm Qwmk6RtLtRG23F+Vokb9233ckMBMnL4= X-Google-Smtp-Source: APXvYqwIydKvpv1tjnbZN9F1ekRR2EO+V9YsgDB7BSIRSEQi2zWwNNwlNULytMuoWI4eUgzyGxCYhQ== X-Received: by 2002:a1c:7917:: with SMTP id l23mr5276198wme.60.1571934509184; Thu, 24 Oct 2019 09:28:29 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id r27sm42606124wrc.55.2019.10.24.09.28.28 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Oct 2019 09:28:28 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 49/51] hw/arm/bcm2836: Rename cpus[] as cpu[].core Date: Thu, 24 Oct 2019 17:27:22 +0100 Message-Id: <20191024162724.31675-50-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191024162724.31675-1-peter.maydell@linaro.org> References: <20191024162724.31675-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::32d X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" From: Philippe Mathieu-Daudé As we are going to add more core-specific fields, add a 'cpu' structure and move the ARMCPU field there as 'core'. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Alistair Francis Message-id: 20191019234715.25750-7-f4bug@amsat.org Signed-off-by: Peter Maydell --- include/hw/arm/bcm2836.h | 4 +++- hw/arm/bcm2836.c | 26 ++++++++++++++------------ 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/include/hw/arm/bcm2836.h b/include/hw/arm/bcm2836.h index 97187f72be9..92a6544816b 100644 --- a/include/hw/arm/bcm2836.h +++ b/include/hw/arm/bcm2836.h @@ -35,7 +35,9 @@ typedef struct BCM283XState { char *cpu_type; uint32_t enabled_cpus; - ARMCPU cpus[BCM283X_NCPUS]; + struct { + ARMCPU core; + } cpu[BCM283X_NCPUS]; BCM2836ControlState control; BCM2835PeripheralState peripherals; } BCM283XState; diff --git a/hw/arm/bcm2836.c b/hw/arm/bcm2836.c index 019e67b9068..221ff068956 100644 --- a/hw/arm/bcm2836.c +++ b/hw/arm/bcm2836.c @@ -51,8 +51,9 @@ static void bcm2836_init(Object *obj) int n; for (n = 0; n < BCM283X_NCPUS; n++) { - object_initialize_child(obj, "cpu[*]", &s->cpus[n], sizeof(s->cpus[n]), - info->cpu_type, &error_abort, NULL); + object_initialize_child(obj, "cpu[*]", &s->cpu[n].core, + sizeof(s->cpu[n].core), info->cpu_type, + &error_abort, NULL); } sysbus_init_child_obj(obj, "control", &s->control, sizeof(s->control), @@ -122,10 +123,10 @@ static void bcm2836_realize(DeviceState *dev, Error **errp) for (n = 0; n < BCM283X_NCPUS; n++) { /* TODO: this should be converted to a property of ARM_CPU */ - s->cpus[n].mp_affinity = (info->clusterid << 8) | n; + s->cpu[n].core.mp_affinity = (info->clusterid << 8) | n; /* set periphbase/CBAR value for CPU-local registers */ - object_property_set_int(OBJECT(&s->cpus[n]), + object_property_set_int(OBJECT(&s->cpu[n].core), info->peri_base, "reset-cbar", &err); if (err) { @@ -134,14 +135,15 @@ static void bcm2836_realize(DeviceState *dev, Error **errp) } /* start powered off if not enabled */ - object_property_set_bool(OBJECT(&s->cpus[n]), n >= s->enabled_cpus, + object_property_set_bool(OBJECT(&s->cpu[n].core), n >= s->enabled_cpus, "start-powered-off", &err); if (err) { error_propagate(errp, err); return; } - object_property_set_bool(OBJECT(&s->cpus[n]), true, "realized", &err); + object_property_set_bool(OBJECT(&s->cpu[n].core), true, + "realized", &err); if (err) { error_propagate(errp, err); return; @@ -149,18 +151,18 @@ static void bcm2836_realize(DeviceState *dev, Error **errp) /* Connect irq/fiq outputs from the interrupt controller. */ qdev_connect_gpio_out_named(DEVICE(&s->control), "irq", n, - qdev_get_gpio_in(DEVICE(&s->cpus[n]), ARM_CPU_IRQ)); + qdev_get_gpio_in(DEVICE(&s->cpu[n].core), ARM_CPU_IRQ)); qdev_connect_gpio_out_named(DEVICE(&s->control), "fiq", n, - qdev_get_gpio_in(DEVICE(&s->cpus[n]), ARM_CPU_FIQ)); + qdev_get_gpio_in(DEVICE(&s->cpu[n].core), ARM_CPU_FIQ)); /* Connect timers from the CPU to the interrupt controller */ - qdev_connect_gpio_out(DEVICE(&s->cpus[n]), GTIMER_PHYS, + qdev_connect_gpio_out(DEVICE(&s->cpu[n].core), GTIMER_PHYS, qdev_get_gpio_in_named(DEVICE(&s->control), "cntpnsirq", n)); - qdev_connect_gpio_out(DEVICE(&s->cpus[n]), GTIMER_VIRT, + qdev_connect_gpio_out(DEVICE(&s->cpu[n].core), GTIMER_VIRT, qdev_get_gpio_in_named(DEVICE(&s->control), "cntvirq", n)); - qdev_connect_gpio_out(DEVICE(&s->cpus[n]), GTIMER_HYP, + qdev_connect_gpio_out(DEVICE(&s->cpu[n].core), GTIMER_HYP, qdev_get_gpio_in_named(DEVICE(&s->control), "cnthpirq", n)); - qdev_connect_gpio_out(DEVICE(&s->cpus[n]), GTIMER_SEC, + qdev_connect_gpio_out(DEVICE(&s->cpu[n].core), GTIMER_SEC, qdev_get_gpio_in_named(DEVICE(&s->control), "cntpsirq", n)); } } From patchwork Thu Oct 24 16:27:23 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 11210561 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9E68D139A for ; Thu, 24 Oct 2019 17:32:32 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 7409E205C9 for ; Thu, 24 Oct 2019 17:32:32 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="o+RzDBN+" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7409E205C9 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:48816 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNgyN-0003av-2A for patchwork-qemu-devel@patchwork.kernel.org; Thu, 24 Oct 2019 13:32:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58377) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNfyT-0000AO-Pz for qemu-devel@nongnu.org; Thu, 24 Oct 2019 12:28:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iNfyR-00017o-Je for qemu-devel@nongnu.org; Thu, 24 Oct 2019 12:28:33 -0400 Received: from mail-wr1-x444.google.com ([2a00:1450:4864:20::444]:42904) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iNfyR-00017d-D0 for qemu-devel@nongnu.org; Thu, 24 Oct 2019 12:28:31 -0400 Received: by mail-wr1-x444.google.com with SMTP id r1so17002372wrs.9 for ; Thu, 24 Oct 2019 09:28:31 -0700 (PDT) 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=1dJwftnWoG2W4EHlFbqacOwE41DkQDlktBfsa5t+Z30=; b=o+RzDBN+eeMVcg5RR90hEIrRAWIavD1cz2s96JG6cLAUEZroHYqUkNIHm+WV53OGFc OT2nWEy1GGrwfwLEeAlZcS334lKZhM4KwlOe4DildIcibRcYlOvY3S6fYZNXFr8OXEb0 dr+M4asTEO0JqTyFqcNOwpIma0Dc2FQDeF6FvCemHTQWSC9haL6hZGuKfiIW+Jsi0Yb8 O5UTI9JeyaylfO+TJn0Z7MCtpvKxzVhgH6+Ub9jfZ4nRrZRP3bR6EQAD6+GnU8/m1KPU MnZcLBWFIwD/TNNpYmwL2iS/xXwlF28ErXJv8/7NDX8ChTe7lEwBKv3fCZQPc552UAV9 wLzQ== 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=1dJwftnWoG2W4EHlFbqacOwE41DkQDlktBfsa5t+Z30=; b=o4zRgeB6q/NvLk5Rpa0/xLgeUeDnxub5X/ihcdhyhczqlPd0v078Jf/Jl7FzPXZ2qY f06ZK14RozlJ4dy2WouUVirDA6FMpmNJMy3nIKCiWUKajdMQY3eA4Z5rY0KEG53Aapd/ WbWTY0kiGWtJgdNtU8++d9g+k8Uq4x2fNTHyVUm/GPAXK8SZwFUg82WjvTdOi1/EnUza BbcDnn0X23x7BXyjP36zGuNoe8/WGQf0p8IvlYzXPw9BJaYwhDqedwH2QS0Fw+U0CQjj fzl7USPvHCKrxZ6aXmcarv91Exf3Ge7zX3FoL6m2fZjvMwC6Ro7fJzX4ZBLRJBychkQR xEdg== X-Gm-Message-State: APjAAAXxU45QzZEIi01rFFzjVzGTk3GxzjOq2FXZH6UHWP48p2FeGPGb ihD/2/Ska89v+tobbhLmEiz5u/F8nyI= X-Google-Smtp-Source: APXvYqykSAcFI9C59gKswgeyeg6Pa9ib3QUOlXAy/dAIFZ16lq8LKhPCUH5oXcZ1C6AOtMErftZFwA== X-Received: by 2002:adf:ce87:: with SMTP id r7mr4585736wrn.307.1571934510211; Thu, 24 Oct 2019 09:28:30 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id r27sm42606124wrc.55.2019.10.24.09.28.29 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Oct 2019 09:28:29 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 50/51] hw/arm/raspi: Use AddressSpace when using arm_boot::write_secondary_boot Date: Thu, 24 Oct 2019 17:27:23 +0100 Message-Id: <20191024162724.31675-51-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191024162724.31675-1-peter.maydell@linaro.org> References: <20191024162724.31675-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::444 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" From: Philippe Mathieu-Daudé write_secondary_boot() is used in SMP configurations where the CPU address space might not be the main System Bus. The rom_add_blob_fixed_as() function allow us to specify an address space. Use it to write each boot blob in the corresponding CPU address space. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Alistair Francis Message-id: 20191019234715.25750-11-f4bug@amsat.org Signed-off-by: Peter Maydell --- hw/arm/raspi.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/hw/arm/raspi.c b/hw/arm/raspi.c index 615d7558790..6a510aafc19 100644 --- a/hw/arm/raspi.c +++ b/hw/arm/raspi.c @@ -60,12 +60,14 @@ static void write_smpboot(ARMCPU *cpu, const struct arm_boot_info *info) QEMU_BUILD_BUG_ON((BOARDSETUP_ADDR & 0xf) != 0 || (BOARDSETUP_ADDR >> 4) >= 0x100); - rom_add_blob_fixed("raspi_smpboot", smpboot, sizeof(smpboot), - info->smp_loader_start); + rom_add_blob_fixed_as("raspi_smpboot", smpboot, sizeof(smpboot), + info->smp_loader_start, + arm_boot_address_space(cpu, info)); } static void write_smpboot64(ARMCPU *cpu, const struct arm_boot_info *info) { + AddressSpace *as = arm_boot_address_space(cpu, info); /* Unlike the AArch32 version we don't need to call the board setup hook. * The mechanism for doing the spin-table is also entirely different. * We must have four 64-bit fields at absolute addresses @@ -92,10 +94,10 @@ static void write_smpboot64(ARMCPU *cpu, const struct arm_boot_info *info) 0, 0, 0, 0 }; - rom_add_blob_fixed("raspi_smpboot", smpboot, sizeof(smpboot), - info->smp_loader_start); - rom_add_blob_fixed("raspi_spintables", spintables, sizeof(spintables), - SPINTABLE_ADDR); + rom_add_blob_fixed_as("raspi_smpboot", smpboot, sizeof(smpboot), + info->smp_loader_start, as); + rom_add_blob_fixed_as("raspi_spintables", spintables, sizeof(spintables), + SPINTABLE_ADDR, as); } static void write_board_setup(ARMCPU *cpu, const struct arm_boot_info *info) From patchwork Thu Oct 24 16:27:24 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 11210545 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3B67E139A for ; Thu, 24 Oct 2019 17:28:57 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 1166D205F4 for ; Thu, 24 Oct 2019 17:28:57 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="IW1U/8Da" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1166D205F4 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:48734 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNgut-0002qO-EH for patchwork-qemu-devel@patchwork.kernel.org; Thu, 24 Oct 2019 13:28:55 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58381) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNfyT-0000Aq-TP for qemu-devel@nongnu.org; Thu, 24 Oct 2019 12:28:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iNfyS-00018I-TV for qemu-devel@nongnu.org; Thu, 24 Oct 2019 12:28:33 -0400 Received: from mail-wm1-x343.google.com ([2a00:1450:4864:20::343]:38070) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iNfyS-000182-NN for qemu-devel@nongnu.org; Thu, 24 Oct 2019 12:28:32 -0400 Received: by mail-wm1-x343.google.com with SMTP id 3so3221451wmi.3 for ; Thu, 24 Oct 2019 09:28:32 -0700 (PDT) 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=TW1rHEa4Yt+Clo9YX+nLhtNEgx47fDesU2q7Xi3+SMM=; b=IW1U/8DauZCiUdzyrb45j+OZKBHmnRYYJ0HrHRmfTzQdGpKQMtDk5HGT7M/jXpcpZd iXx+9HL5kQUb8kz3yzM525dIguE9H89a6sv/MlRuwwsLZIQUSo7+IewoQIi5cFlVBATS o1lB4rKrHJZLDTy+1DFdfB0Zm3dA4RD2WQNiWDD1Gp+37u23MZE+lzbTwABj/X777SHj Df4Bxwc/lABBIVPsEo1JD5noz5NSgBTd9CyTrfUPd46DfXEwcDI0yqqMnnt7i7r0uokM RbFW5kyHu2KSIde1fqXotBs/c0hKYblGvSLKjYpy2mgjXES7HztkYPdUufAYq819TReX 2JPA== 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=TW1rHEa4Yt+Clo9YX+nLhtNEgx47fDesU2q7Xi3+SMM=; b=kEHgBAE6BtnBICPpSVHltj0jRhPosDIjkIINmhY3jSXJ9mLehsQb5NW92wUVEZFuqL GpO6CyLxvUGxaDLeos3jhxJBFKwjd4tCbZkJs+phX5iiISjP/oYIwfMFJhiiyiwnGEg1 6hVUcknazpvLex0TfuQPaJ0gdwgIdcHTIREg5B8WkAPvT2c3f9nJMQj2slClecZPXq1n nfIhz5wzvv0wizzMjlmrTszahIA+Kt2iUhj5RP7jO4rkGH2hDflcCdv/6gxbA8ddB2sf Y83ygC98KIiM96msFNWgGo8OjlRqFP6QicgrBOJmDGsKKbGcIeroxqqL3zvF8lagcTbm JX1w== X-Gm-Message-State: APjAAAVirvn/iL+pZpBNgVjBsnwxDovWHKnzt/cSu1h7XkOiVUrcpSRY 6b4Es6/KO+UJehnALnjqlOt+mSnE8pE= X-Google-Smtp-Source: APXvYqwDb1l8z/AUSogAhBAPDc0lzKHagIm7TSIzRnEV2+8es246w946LzWld3yIbFz1Az5sTgtCOg== X-Received: by 2002:a1c:7517:: with SMTP id o23mr6001285wmc.34.1571934511495; Thu, 24 Oct 2019 09:28:31 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id r27sm42606124wrc.55.2019.10.24.09.28.30 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Oct 2019 09:28:30 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 51/51] hw/arm/highbank: Use AddressSpace when using write_secondary_boot() Date: Thu, 24 Oct 2019 17:27:24 +0100 Message-Id: <20191024162724.31675-52-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191024162724.31675-1-peter.maydell@linaro.org> References: <20191024162724.31675-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 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" From: Philippe Mathieu-Daudé write_secondary_boot() is used in SMP configurations where the CPU address space might not be the main System Bus. The rom_add_blob_fixed_as() function allow us to specify an address space. Use it to write each boot blob in the corresponding CPU address space. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Alistair Francis Message-id: 20191019234715.25750-15-f4bug@amsat.org Signed-off-by: Peter Maydell --- hw/arm/highbank.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/hw/arm/highbank.c b/hw/arm/highbank.c index f1724d69290..518d935fdf6 100644 --- a/hw/arm/highbank.c +++ b/hw/arm/highbank.c @@ -78,7 +78,8 @@ static void hb_write_secondary(ARMCPU *cpu, const struct arm_boot_info *info) for (n = 0; n < ARRAY_SIZE(smpboot); n++) { smpboot[n] = tswap32(smpboot[n]); } - rom_add_blob_fixed("smpboot", smpboot, sizeof(smpboot), SMP_BOOT_ADDR); + rom_add_blob_fixed_as("smpboot", smpboot, sizeof(smpboot), SMP_BOOT_ADDR, + arm_boot_address_space(cpu, info)); } static void hb_reset_secondary(ARMCPU *cpu, const struct arm_boot_info *info)