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: 177537 Delivered-To: patch@linaro.org Received: by 2002:ac9:3c86:0:0:0:0:0 with SMTP id w6csp2393133ocf; Thu, 24 Oct 2019 09:33:31 -0700 (PDT) X-Google-Smtp-Source: APXvYqxFJysG6ItixgZdquIe7D8VWG2kTVXis7qvGO0lNKdi+J0f2orcI0TTc3Rf9xV+6+PjQ0nz X-Received: by 2002:a17:906:8288:: with SMTP id h8mr11509656ejx.251.1571934811019; Thu, 24 Oct 2019 09:33:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571934811; cv=none; d=google.com; s=arc-20160816; b=ZD0R0tL6Imt4WMrHSOEtrJlIopL6ScfniLzaDpzSCAddBoK1KAKX+M1Fg/viTBH5mx G+KDAy6yQYgCy30FZj6IFNN18OCJvsc1DYo0cwwTQGUMe5kXpaeahzp+veB6hj0ZeCzU 2pg4/2c2iY1936xMdFE1fMWmvYXYXGkU2vxlomvmo7XtKKy7Btw39BkE+qgxcJoZqB5t 4Jfd/eO0flzeNFrPg73dk88eKoJgVvpEOqbwcHJ9KGtOqHx0UVVtbZxMINKngKNKEahr du8UY2jXJW9HoZLCAZZCPjsB3q/UEbKgKacICT+26iQ0Dc1gdraEXrYr9YitmvqdtRMz 1n7g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=eiQ4IS489mOFVCAyCVWUyEDk9Y5TrLD5uNTu22NV1VM=; b=nlUn29Y3NS+yXq8c4m/DjDiKadZLMsbk2GurrFgQzP8spBvv9a6B+Ld/XltR0StxcP VtZ5mOvGdsJwMGKgay1GK3lZmkHkBAPw6MRUbsPz6HupTyxj45Bz2uJyh76X+DnxWPub grrKL8jaqrW6hnslKN5Va15LQcW8dGYqDScpvjKyIPdH+bYlrgJPfvDxuNgNW4nrUQwK XgV5xmnEUbHu+1w9obBC18skjWzwmm+Vqs3UhUlvyANl1Jn5Tlsb7/s1KgnWVncR9HXE un6iahuQqEUL+Fg19JjU/fvSFbOlLn53GLefjZmvCSZMD5R8aLcclrke5pz+fGSBxKlC xFgA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=bhouM6n4; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id e1si15441326ejf.28.2019.10.24.09.33.30 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 24 Oct 2019 09:33:31 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=bhouM6n4; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:47258 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNg3F-0000Tc-N8 for patch@linaro.org; Thu, 24 Oct 2019 12:33:29 -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-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+patch=linaro.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(-) -- 2.20.1 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: 177556 Delivered-To: patch@linaro.org Received: by 2002:ac9:3c86:0:0:0:0:0 with SMTP id w6csp2414427ocf; Thu, 24 Oct 2019 09:52:13 -0700 (PDT) X-Google-Smtp-Source: APXvYqz/xgQVrg7DPE70HnrfpZ2zt8F13LGgXSoy6fzeH44Pin5ybg7dH3pwHfNw22UKbMSO6VeP X-Received: by 2002:a17:906:6bcd:: with SMTP id t13mr27858037ejs.231.1571935932879; Thu, 24 Oct 2019 09:52:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571935932; cv=none; d=google.com; s=arc-20160816; b=QorWRw/9s2VtBAxFs4HqT5cHHNdDNNv12FEnWO6c40qqc+lnOQPJWc4WFqdSk70Ouh jUSru4Lsh3pqBcHk1FoDVVBeFkm/VS3c0RJoxzLkdymehl2Wa7LhWmkHsXj9qgB4dEo9 geH6hCAd+2MiOv2psrfvG1azXG+8QkeXjCH9esO4jXJCxq6ZWDARpzyaEZiJKtXHv3Zt YiwVQLyDoxmoJ3Vq2Pw5CdJgiiLxgdE/k3R5/6wIrvjYI8YRaMw6MhWpCcj1Yzt6ff+8 ZMcMfayv8JmUbA65BlsZ2MfXM27GRDQoCHajFEAPzH9VJHy5/z8reUlUnotIE3svy5X4 n2MA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=xpXmKegf0IiPtTBa9NzxMTzRYFfOthHDRfOU4bFkq2w=; b=j2Fzs352Xr66VpLEkhshJDnf2LSHWTlkqahMpgV0Gi6XC0mDBXuqmf08dFmDm9WiXd lz08i3sFeynZqwY3fhcfJwm3JU3968uLyP1yS2CABbLS8Q1EizPQYwplEcugiYkAlUMd 5n+zvMb7s4wp7LXr50Sbt4SFCs/hnHGj38z/Vhw6eJEX3a3ooG+EQK4Iwtyulv2J2dFk lGyiKFqdxMYRbNxjiqCRbRCU48RZpfFvfeDPAJqNQ88gjIMsasYrIsI74bNf22xLoQLs DJX+2gJpaMxdXcnXB9F/hFBidtjj12OA3HobOB1LY4egE10JqgyhqBrD1K6ZYVe9iM2G 5Rng== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=mRUJ6G1O; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id fy18si11149007ejb.371.2019.10.24.09.52.12 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 24 Oct 2019 09:52:12 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=mRUJ6G1O; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:48006 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNgLL-0001d7-EF for patch@linaro.org; Thu, 24 Oct 2019 12:52:11 -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-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+patch=linaro.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(+) -- 2.20.1 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: 177557 Delivered-To: patch@linaro.org Received: by 2002:ac9:3c86:0:0:0:0:0 with SMTP id w6csp2415418ocf; Thu, 24 Oct 2019 09:53:07 -0700 (PDT) X-Google-Smtp-Source: APXvYqzNrLcfZZtyvikteXYIEZkc+Uf75sOgqVsAf66IrQ9/eNrDA7Ur07nr9DYYCCpqH60srlCn X-Received: by 2002:a0c:fd63:: with SMTP id k3mr3503432qvs.185.1571935987228; Thu, 24 Oct 2019 09:53:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571935987; cv=none; d=google.com; s=arc-20160816; b=aPlfDP1nsRzQq3zHmt7/dp4kshlGs9MgL3o4oXuu2Qrr+Q1zl32MRE2xr/coLaumJw Rm5G41qlQWWzvWftncn7qaxyWp7K/0B7daioOsFmeg77R5eT9leKwmObO4+OvSopDlYS o6kg4rDHH9yP3ZhHzmR0kGvVYCIKW+MO2LxRGAbY12uvQ6/5cIt4TGwdoKOrnOcHfMLf k9QU84hWiM3o6OwlFAwAb+FCZW6p8CfQEBBnKj80r3B8uJTDwyfZlldOzVbd4L8lUci0 eev+CR2K6wK1sC7k/indSwW1A9E36zjvQc4Yn68VEWyTXM3gsfbF/VIDIDA2WOzugavP AsQA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=cpjzzf90ZZlnCC/zG71N3R57DXjC6KFtdGEnCvJDP10=; b=ZlxHowLIagzvzUDIqtafuJTIrS8GZfHvKbRv4xeRdfdNbQTY6YpS6HevY8TZqvJVkv rSNNNNjdTZuatgchGljqGNsmL2EdHCEt69fIwV/D7ibj5X5O4xF1+Jxoxs3G4KsJBfc/ nJnNtzxIbGWQ/Qoh9bPstlV17c+OErX3L+v+t7af+2wdTnUxopK82/mwJKgphtsVI1Jp dItO4SORz2m2ELdsb7I25E/j15KfztguG03gB9n3qB7WDPeKqh4jpqd16vxe3hhzHneA PWe5ZqW/W+773QL+qbJJQWVedToKrF6uV2mcMRhZa1d2P59CmzswQKDpOV/h9QDQphAF 3UtA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=pjTaFwQY; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id h1si23631589qvj.198.2019.10.24.09.53.07 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 24 Oct 2019 09:53:07 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=pjTaFwQY; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:48036 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNgME-0003AS-4C for patch@linaro.org; Thu, 24 Oct 2019 12:53:06 -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-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+patch=linaro.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(-) -- 2.20.1 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: 177538 Delivered-To: patch@linaro.org Received: by 2002:ac9:3c86:0:0:0:0:0 with SMTP id w6csp2394024ocf; Thu, 24 Oct 2019 09:34:06 -0700 (PDT) X-Google-Smtp-Source: APXvYqwxSv8SglcPQRiZ5SkexQCXP4LEtjg9+cUTsdeUxbkrOAf8ikEWHheplHkCDR5tHadQou4j X-Received: by 2002:ac8:b46:: with SMTP id m6mr5235675qti.262.1571934846641; Thu, 24 Oct 2019 09:34:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571934846; cv=none; d=google.com; s=arc-20160816; b=YVl7xm7i7iv4nXnCwb/Jv8pKZtefNpwq7JUp7UIPphfL2109NLmugYT0v+ZeOOBYWk LYsVBf29yzQRGpOZ55/s8SbeEegHrQviLeStGGJW+oLbFEo1pdb98pFQqxNLINWQz6r6 VIgcvxf9Wnl+cxxNOIpTC5n97WAY/V/Wtei62d3P8BVbPzubVCrT5eI1jKAkT1nlGtTM tOh2TRomIMMfsRq7xAKU0OojZyP5ItfZxpVFW7CzTu3UcSf/FFinvdCIBY+mGyvpqXEU C3zH4L2DsYAheK9C4IZElcWbhhcYE16y9YTbQSQEl7jmesbM58Kv403vovADdTeGd5eZ 0xrA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=bYwTl3jw7Dzln0o9WYtKWCimWjsmaSgObx3Y/zWbSwc=; b=m/uhx1fYjrfmqQP0+qT9WPk7ffK2Z1oTO6ZGk3Mexw8Mynm/+qYVtP2pCYnXy7cLLA QQgpymlV7nJoCuYWnbWitdlcWUnp/lPIdV677qVHYymTdBKgjfwUVLRAyjFJZKUOr8/5 1/76MN8i8QENFOvmiSR9VTZclQC1wnq9IiYwbHH7nKz2epIkEFWrYijs7MzCbx8tu1Cu +Yb5WKbmuMXGcHbA8W6LfgmcJn9Hr0Gqc4KqjzRpK68sfA7gLkHJy1JEoltgNf6eA0ci x9vV+e65szHaiYj9HKxOTR2bRDa7IxIa4arHsldMtgY6PFaRuxSB0MVDet184mHpfPew 0zKQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=dr9H6AZO; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id z18si22683169qve.50.2019.10.24.09.34.06 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 24 Oct 2019 09:34:06 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=dr9H6AZO; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:47265 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNg3p-0000jG-5C for patch@linaro.org; Thu, 24 Oct 2019 12:34:05 -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-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+patch=linaro.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(-) -- 2.20.1 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: 177560 Delivered-To: patch@linaro.org Received: by 2002:ac9:3c86:0:0:0:0:0 with SMTP id w6csp2418563ocf; Thu, 24 Oct 2019 09:56:20 -0700 (PDT) X-Google-Smtp-Source: APXvYqwWw7yRHcuQZMNLFUoRupdDJlMKXFSl+O+AtSWxndQw+PiTY7uh1DISwycsD6wyDJDZMXie X-Received: by 2002:a50:cd53:: with SMTP id d19mr14606377edj.197.1571936180839; Thu, 24 Oct 2019 09:56:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571936180; cv=none; d=google.com; s=arc-20160816; b=giFw5gqPQqIEOj0iUd9kv+zCZBmbtWWNGuX7aXzt9IXRZ6rQdPtg3Z5hxjpD9qBrNu 3UKQgs0gFfA8TXG+eJCRtvm8dHq0u7xHHtgHjQthdLqoyPbWjbZ2un0z5Sf1+ZsIQxwd 85WhSkB7KOYHd3npnRDDGt/eZFws1qUkBTtt98s1jYQ4qGcSta+6+NQfBdDY0wTWbVxE DIckj4UvdrIY8zluEU/I617aJlZM/JNrGaVUzcxXKIDBrMxD2rxoPsUiJF9jDUVZmxqh +EJ/KNWCs0g+W/7lWd1SapyRx+fDplk//z+Y4CBILaBW3e9k7eQ11bC2RxXejPpqFOox 66MA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=KG6cHPR+km+P0qCVntKHolnh4Cws12yKWCSVL0d/8TE=; b=uSM/Gr4U1bRZyZMVmBP4OvlgF03d7sMEqH9EhnRXfeCO+AfBDrVZAWLPRDPdO+FOVI OOxQWWmVIebDBW5Zg7eH6AEj/oZVPsh5GLurLGKXhqWHWZkjPdsyjUjKv1oCjjycVnha pFbbdgevcjPAXzdNcxPXqSALC2WVY08ySt3TgHzc8JyDU+wtjTghk9RwYnypLzJMYDf/ OwKnybLSCwheKom0BuMl1PaysxJxgabPS9pqpT9sU0HMNYdaJgNyyvMwlke7/TjqjVlK xcKA2R3dawjDxgTA8v0LjFuunO4K3whKm40jjQWGS07wNIuMsGUjlpQVNzcIo7658aWd GwFg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=maqFf5oD; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 17si14113949ejx.213.2019.10.24.09.56.20 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 24 Oct 2019 09:56:20 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=maqFf5oD; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:48106 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNgPJ-0000LK-VR for patch@linaro.org; Thu, 24 Oct 2019 12:56:19 -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-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+patch=linaro.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(-) -- 2.20.1 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: 177559 Delivered-To: patch@linaro.org Received: by 2002:ac9:3c86:0:0:0:0:0 with SMTP id w6csp2417335ocf; Thu, 24 Oct 2019 09:55:05 -0700 (PDT) X-Google-Smtp-Source: APXvYqxvfyiiNseqiqsLg45ZFRfbcWSOcZV2YgN5JAeFMHhPmdP7CzNec+OM25/6lxYEVV6W8Ldz X-Received: by 2002:a37:4b4f:: with SMTP id y76mr2331315qka.488.1571936105001; Thu, 24 Oct 2019 09:55:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571936104; cv=none; d=google.com; s=arc-20160816; b=j6NGr1R2WRGdhF/YP0j7IaAIZ5UZCZz72aR+8yDBfCyjjE9DuvrMnL/T2JyJ37f1t4 nFNYOMmU+/Stt/KQwWMXuvEkOCGjdQbhc4Tyk6xAs51bcVvBKRQmXRXJYAnyZkHykAuA QKjfgWK4P8/qT3RWvA4BNhhRnotmPXtUavO/VdzOjSlWmpN0hLOuI/S1uoNq+RUDRQme dHOoeoT28dlSTmWOxwweiqvGZZkBAVXOu4f0Hz2qJ5rc8SZDeb0jyZsTxtvOC4i4cFKN 7cm/VcZVuMer70gpUG7Y0wAViG9WPWi1RSbXRLyhU5ezNc1kMe3R4UmJF2WP1Bbf/JsI NvEA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=W/AkGYR57m74r9FQYLQ/SGWlTLm2K1Vi5lkbHPvwzOg=; b=w12UlJpWyYHXO4ERkysRdlC3bZT3U5gXguqn70hQVx6v8GmOviYaEmLWcu5qtL1JTX PWCQQ56zoyC3pld4RBMJRFG8rnfJSaV/+8M0cej4UrCqjOlZ/mtYzkRe8lFbCK6C9R6N VlDylpLYpEElOGzeF1bSuwxflad2JcCGsMs4hga1VOvA9jEOdURjI5JXw4fZ0Dc9mmNE 07glgC5JzNwfH3mL/rXzkrnnqoDcLWjurNht11g6RTz0zrnrGmAK/kLCPsOyVmJVvFvY MCKhenfUsTyGj3ZGfkbq7HR+GSBamijukw2AXUudXiep3es8G8oIHBCsflQKhLClFj02 7Zlw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=v+ohkY56; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id e47si25085567qvh.93.2019.10.24.09.55.04 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 24 Oct 2019 09:55:04 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=v+ohkY56; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:48076 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNgO8-0006Gl-2T for patch@linaro.org; Thu, 24 Oct 2019 12:55:04 -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-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+patch=linaro.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(-) -- 2.20.1 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: 177564 Delivered-To: patch@linaro.org Received: by 2002:ac9:3c86:0:0:0:0:0 with SMTP id w6csp2421398ocf; Thu, 24 Oct 2019 09:59:20 -0700 (PDT) X-Google-Smtp-Source: APXvYqxZS7g0znzKjk548eZlMQIFw7J7wn1he4vH2uc18fJ0ON6rPW0PevbuyDFeYiZqNUn5Z7tC X-Received: by 2002:aed:3063:: with SMTP id 90mr5344836qte.242.1571936360797; Thu, 24 Oct 2019 09:59:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571936360; cv=none; d=google.com; s=arc-20160816; b=LEHlU6F9ednTqfH3sg8VBB6mN7lH+hBCcWUaYrnLy3iA8JzR1Xj3xBQwV9w7PO2vkZ 3yLYBX8T+7smzYAP/QRgfKys/CigiM+SoVL1XmjGgcpLBy1XjBZiUvDlY3vIjtEZRhqH boBVGxeLubYts21d64vXaC3DrTwCPWHIoQkJ3tWnzZLdL1K8YG9gBuBxLEoxvGNGmV0v Zlcy5n2MJQd5qpzuY3oGT3KwgIpw+86pgqwa09cd82YR8MZ9RVWz3i49Md8cPGlwbvtF cDnc28VcOWb7QPIc/DZOKqocuWsfV9ENUvIH5fp0+elPtI5BOhidrhkkHsvdVtzdpqFb dtTg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=Mk85QypYDHQ0fOkvmDB53SsHXryn+nYp39hNgWX4kxU=; b=OX0t1TcgZeCK/DmsVbOIC4DaWq+a0jDq+mSlRF+Ig7GcnbFV9RR6KJ62tXzP5AQ4lX dMwSa86uHgi+PIsyz9VKVND9VlGY/BgO7HCz14dS8JEqTPmaithElI6nfFLa/0ev3Umw fzeWk2KVrZys0rbz6g5dZi7lAMlh+yW+jn92lVkSojzm65EHIYP/RAUnbfS/Qz05x9ys WXcWu1EGe5TdYKg8HV6WEVtpZEmQa/NBqFWqip8NqFC/8dfgENU4YdLo+GJvOBMXQf5G mvSv1AiY/Kk8vLLoZVOoinxufqYnwjBNiRE45nI1j902MVWfpouDm+2LTVgYO9tjxfcn Esyg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=AGMo3tQg; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id t46si13160097qtb.168.2019.10.24.09.59.20 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 24 Oct 2019 09:59:20 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=AGMo3tQg; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:48158 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNgSF-00067t-Sy for patch@linaro.org; Thu, 24 Oct 2019 12:59:19 -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-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+patch=linaro.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(-) -- 2.20.1 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: 177562 Delivered-To: patch@linaro.org Received: by 2002:ac9:3c86:0:0:0:0:0 with SMTP id w6csp2420394ocf; Thu, 24 Oct 2019 09:58:16 -0700 (PDT) X-Google-Smtp-Source: APXvYqyQHNyO+ejLwJ0JaXG7L0ceAY/yCbCvKUi5tZLvIaxSYnVkSEkFcr3XLiLmwGag0sU9N+Hc X-Received: by 2002:a50:af44:: with SMTP id g62mr44907036edd.164.1571936295950; Thu, 24 Oct 2019 09:58:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571936295; cv=none; d=google.com; s=arc-20160816; b=rf0kpi6pvItki68pcBtr5SxTTWJefhkrV3KmNSnfLWSxwjf/IXBcX0oJ5ojxLfsAG8 EOusIOIYIBiTjjHRvt/KmNq/QilZ/a5cAZEbHuS7e0ozFaUw3UVP/rEPF1sPhoLDEf1f la3Qs8GSO+Ufw/WK/nCnunXsuj7YgEmPdtNuMCvP1PnQf+P5V1FFzOwxLXEHKqrciFa7 8MD7BQOPXLeN6a2lgNV9HxQ5XVZvWfur4DOPc3tcjeLOht0bQUdUTn67q3PzzXoFR/93 1cn2sYiEA1ZtmnrGJA9cllG1flmQxIjy8RmmKNJ76v31FTddHEtOLspD39DS+rmscC4U 5czQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=0lnGCVKOKwt9P46Q56BLi+6ul/rpICS/xFMS4taRSZM=; b=CXbx94nkJCoz/Fjv/xeek4ClL4ZXp6iUTYPhSRRVNnPQvQA6Ehn1q1uCtZEEWq/hfW upKOl8CQTsOrB0ndGthSaJMFNhO+G76QMmhYHBYuVO28yrekCdb+sGR6q2s1UhBs9X34 3V93wAuqRJf4tEl78/zWebLLvLXJfOitjbhN/SQD5QsydEm1/UVrAiLPiqDB13gqoqCK 5pOXAJjXCQVq0t3rqPuzYrtqdu/uaRkhmrMSPWVJPKctBIv9hqJMNCANPIdhx+bxHMLq EL7rpjcehVx4+9Vca97Kj+Ra2JWb8qFNOMQfTs/ZwYqoIt8tu25wGnGzLeh/pmvqZccW 6WPQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=USm43yl0; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id c1si6850117ejb.116.2019.10.24.09.58.15 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 24 Oct 2019 09:58:15 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=USm43yl0; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:48144 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNgRC-00048a-78 for patch@linaro.org; Thu, 24 Oct 2019 12:58:14 -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-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+patch=linaro.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(-) -- 2.20.1 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: 177563 Delivered-To: patch@linaro.org Received: by 2002:ac9:3c86:0:0:0:0:0 with SMTP id w6csp2420715ocf; Thu, 24 Oct 2019 09:58:37 -0700 (PDT) X-Google-Smtp-Source: APXvYqzkrjC/gPCBxm8/9SEXFlGDvUfYNMik2d7RGIoa5YfQ2h56XX/n0V4i5Z0oyUYcZ3ik4QWJ X-Received: by 2002:a17:906:6899:: with SMTP id n25mr3808233ejr.176.1571936317309; Thu, 24 Oct 2019 09:58:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571936317; cv=none; d=google.com; s=arc-20160816; b=EepRVwY/16rw6KJ+dup99JU3c9WHll7F6Al9+jTmoykxcszvVhUqBuZCjrinTe8QlU XpWsdbnPQSQfibIA/9LfwA6bJcO81f2UqYsYSjaIPLMDNHjfdPvL5m/YP81U8Y3Sr/Oj JCXXc5V+W6EwusSEuzGod9iu2mVaoaCvFdPIh9+iP0MKTQfKuqfah7Aw7jv8M32+YM4I hjb1EjV0UfhbMppFte0eSCQ7KMxWBm+g4ECVPqVf0zLibSLe4ZfCEJ4CE2PDKYqWFZhC g7YwDchdMxeJIfsbBZ9o/LGiJGEBWxTGJR53gP79hkLy9uWno9dc29ziQ1VimiPaLHSf HHIQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=HFxRD9cQcWniuYeniFsehWwir7VzmPqYaumnJ4Y7pcY=; b=lwrM9reKQOVva+EF7FD4Jqasc9xcHiRgaNRCzjE3JjHLhJoIIojQgrB3KFn37seN/R Zv7XsmNgnVMp1ksgModRXroj6bdd05SEIuZLdy8k6NJN46KwhY1L2/F0gogPklg78o+5 3JR+JichM0EdyDTTOUAJWk5BdsbOYm8sxXlJFTgKfzuRHzdca/GdjAEq3HhafspnaXI2 Enw5BteS1aH08X/ZKj3qOJVbLGdTQost2pDb0dbRid+ceP64kFRiYVEj38gx8uIGHFAq RuOquKlrUG83NOSKHksv4aK5ZTFTj86fs2BKoG2uXBEFe9NSy44istkhk04UBuC52u7y yzsQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=yCg1sKpr; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id y6si7107669ejo.397.2019.10.24.09.58.37 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 24 Oct 2019 09:58:37 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=yCg1sKpr; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:48148 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNgRX-0004IS-JX for patch@linaro.org; Thu, 24 Oct 2019 12:58:35 -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-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+patch=linaro.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(-) -- 2.20.1 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: 177539 Delivered-To: patch@linaro.org Received: by 2002:ac9:3c86:0:0:0:0:0 with SMTP id w6csp2398659ocf; Thu, 24 Oct 2019 09:37:45 -0700 (PDT) X-Google-Smtp-Source: APXvYqwRKDPCFcsm/R6Mm03YpsfazfjJkumCIHbsi1/Esbs0D5IHzW/TwrdX+EYFmRWLWBoOm2DF X-Received: by 2002:a17:906:70c7:: with SMTP id g7mr39510223ejk.9.1571935065047; Thu, 24 Oct 2019 09:37:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571935065; cv=none; d=google.com; s=arc-20160816; b=PbYd5Y2oiEO4lpFbf9knUFY3ERULuWFixiSFWep5dP4z9G4FOLOFrwMC/gwAP5KQxN vC51Aed/u6HP5bMexvsi3PyBJoYdNmqt5Qj8qbA7yT+H48A7NOViNtjhw3INQ4XplLRz lSuWTDj8ug1sXoWuac188iVr/ljwhQf4T6uOh1REQh+iKUHibpSQGQISukdrM/QQ2C4a idIeTVvWGqQ02oZFyWLI3CjG+Ccv/UZiPkOXIudptpeebgyhRLOSmQGLEhfOaH9gv6DD 6PYzwdZxCmFQ4I7Gc75QdnII6CjIRC2KmKDWCtqUgFyazu8xASfaCV5wOazurMyhBTj0 XXJQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=HhJomiYWFoyGiQnBnfLm1DrjhXgk0FPd/bxO+44fxEo=; b=ehIqyJv0NKYWSxBt4DC85CbAVRVryXybi7kXQLcXQBf2Ndw98Ud3YAt6xL4LiGKn9N aK4S2zNPB5N2vQj73yjqG72TIqNIoajumZ/iCLNrxIVS1n2UAJyrcto0OIW210+uu74J yWZjnGYEBQFbpVyh36yJvHeGcUAIKRlJ9JQ2JHcYvkXgYmZ9/LRZqpRGD5MJ6LOaW36w davkhI2Gw/WOLPeI9gCnh/GBW04a0J+NjygGFqfDIdlvwLeCAGmJvIPAd69RpJGcFGey YSsP0Oa+yPHkRlAJhRDtxTJRKzfXhGCEtGGhBxppUIozqj5fWKz5pd7DcZiWDWoEkyap UFvw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=r1LiLYvL; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id a16si9232219eje.336.2019.10.24.09.37.44 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 24 Oct 2019 09:37:45 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=r1LiLYvL; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:47508 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNg7L-0007QV-L7 for patch@linaro.org; Thu, 24 Oct 2019 12:37:43 -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-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+patch=linaro.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(-) -- 2.20.1 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: 177568 Delivered-To: patch@linaro.org Received: by 2002:ac9:3c86:0:0:0:0:0 with SMTP id w6csp2425379ocf; Thu, 24 Oct 2019 10:02:30 -0700 (PDT) X-Google-Smtp-Source: APXvYqwIairayvZfALRaOoUm/BkL26AoAut80WrsZ5i9jDknd/n/j54ZRVEtnB7CzqhhfNvNvhqI X-Received: by 2002:a17:906:3285:: with SMTP id 5mr22506949ejw.143.1571936549990; Thu, 24 Oct 2019 10:02:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571936549; cv=none; d=google.com; s=arc-20160816; b=T/xqd21yG07qRJsYACSY5cxvkERcPlvvBnfZEaNTRE48FQKUyGAkMSDOdYKapt76Lw Ma6ELFTcfdud5A9j1xhNESNWzlLCd19UhFJKGNILleSkmCMZRzqXLcyIA+ec946jp+lP 1aAIaF5EGqhEx/9lKwLoLhshVzV8jUsNOjiBquYvOjtZjv+wfEhYLFlDDwOPGXfnefhT jlsMI1Nez7GolagyBFRYEi6Whk43c6WDFR7Vvw9A6GsS5mnG3PNfzOdmLqRtEMWSQek9 e7kMDyAw/CHybOMJQOf3azX/PKiUqvx7p77VrJu/u8w4d0KPKUP7w1r0HQbBioTgfEpR E+kw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=zVsNlJ5N2k9sc9bIq4CoBW6EYZLcHxwA40pi1YP50Gg=; b=J1FSP4cEWgPsphjT8KvfG4P4vWd1dZeq2MXrKA7Bk8bWyl9wtKj+uWItJbqyB8tz9g cnD9eqpkx01nghgOb36Yw44KWN96TygZLi4eWZYx1fjfzsWg4UVqVZQPaTAlkka/j3Ee dfof2Ls5ZF9OrK1hmL7bHdArogPy5Lqku16n685RfNSKbW6fRR9oHh5EAclE4KNHyIZb 3Xfnm8rLKBCFLqqw63ZiH1tsNhghtj7nGAALJPFdfk/EvAWQrqbUsBBhmOR0x1nnm8pO HF/q/GqJ3C1KBVQctRdEEY4nfM1k7Zs6xcf+fds1B6asb/VZzEOfJ+vuDS/fWsKHD/Ez E5qg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=f+xZduZy; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id v6si10394823ejh.280.2019.10.24.10.02.29 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 24 Oct 2019 10:02:29 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=f+xZduZy; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:48216 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNgVH-0000zd-T5 for patch@linaro.org; Thu, 24 Oct 2019 13:02:27 -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-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+patch=linaro.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(-) -- 2.20.1 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: 177551 Delivered-To: patch@linaro.org Received: by 2002:ac9:3c86:0:0:0:0:0 with SMTP id w6csp2405767ocf; Thu, 24 Oct 2019 09:43:46 -0700 (PDT) X-Google-Smtp-Source: APXvYqxfqeFTSOj5UPl1t9EYWRF/WJ0zAgt1VoD5bbQHBrTCjEu2SoWn0EmGIvmvIPOvpAzik5JA X-Received: by 2002:a05:6402:1107:: with SMTP id u7mr5089464edv.163.1571935426211; Thu, 24 Oct 2019 09:43:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571935426; cv=none; d=google.com; s=arc-20160816; b=N5mncYZtUOInd/bu8AT5Gd+eTFAlepmhMQF/Kdq92+5ap1FzZpAnEyLD6MiDDQolVK lOMqGlYKxZiIHvYMV7Gkt9JNaq84WZSR9GSlC8Ghqkw6XnSuhHqNU8BgzmBCQ6C5fJ9p WTOKw4SGBVV+pYjqvGZflR412JDka+cPTcrsYy4cK2cDb3JwOtCm9JQAxm6tZCvg8LUu Oie3hYkqRraXlM3XE4qXemm9V+7kVcYFPjEB9nytbyTbd+8WpmZnvMeJjJKbATNMWCvc EUA9hhbHylkT3tdkQ3tEKs8FTy04n00IiZF4mTkvmJ4fmzawrQGN5I63yvfU/gvtUBsd bfpw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=0MGAigKQQJD7cJXlO5y60b4rzDCDAg5e78HpKgtRa3w=; b=UyIZt9FtyfdqX8qLdEJ4zUJw+My0QwOVXrIJkwdO7LMo9JRcQ0aZjdVt8mEPwV6scr gfeS3MkKTLdn9l2mo/Q5kVOSkE1iS1NQkLef3UX0pg63TMFKXiKqGeNybc8JtJkidIn0 jvBHCuqJlxMkJxsbq5kYpoIsOixB3n3cwFd2tUZ+EkvAaRiw7qB7KpM2FOCMoim6XPhP CNC3dWve8hIHAi8nLAUxW23O7zWkkmyOLvjLKNUmRMhcsS4FDZYPqlUMXpvFUqe+1EJ7 AcjBBYTwzh2pvJv77A9wROr8IkzLUvoKC5Ne0GWLAb9gLEX8Ua/qpnIPJLIStuaiQCoj 3uEg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="LZ+vNWj/"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id s6si18931607edi.154.2019.10.24.09.43.46 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 24 Oct 2019 09:43:46 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="LZ+vNWj/"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:47762 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNgD9-0003Kg-Nh for patch@linaro.org; Thu, 24 Oct 2019 12:43:43 -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-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+patch=linaro.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(-) -- 2.20.1 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: 177572 Delivered-To: patch@linaro.org Received: by 2002:a92:409a:0:0:0:0:0 with SMTP id d26csp2470818ill; Thu, 24 Oct 2019 10:06:25 -0700 (PDT) X-Google-Smtp-Source: APXvYqwmbcY1ObdRzRhzfqzSrinPFUZqdeG9M7XXWWOElwvZly6AkzLObrkKQLGEFeykgAognvLW X-Received: by 2002:a0c:c3c5:: with SMTP id p5mr15842643qvi.34.1571936784986; Thu, 24 Oct 2019 10:06:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571936784; cv=none; d=google.com; s=arc-20160816; b=uUw1G76GxZmEf99zi92ADYLt33ZQPEYPep8Z6EyGLHQPvkefhgnYGVIHX+W/2tzp66 CUJsdiV/Qxk7bK78U9DH5fLF//IbGYqxnCXQJf4Fz2Kll3stTgLvpOmHyuqIlOYxiTtd E8/T+m1KD86sfBJfycWocSGllPY7M7sK2RfS/L4H+vAtMPJpgyYubU23VWwE7omF1oKo FYuU/AXzRpySsKqpMCsWXLliOefXjMTsHcQJzEOWGwnDbU34j3ZjSlfYKsj4yUcHrPhn LabUfKWCyXKJzIoXwWqn7fkFilhmC7D1varUsQePnKmwNu/I/igU2Bs5qY4fTNDcri/d ZKSA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=VqhS9bMZKhIe/srTN0k3CkMWuCJ4HNLLhZjZXP6/VrQ=; b=XbCyc3XlkAf0AfIDDSPypXs1kPuHVJqDwBAIXCOn7AHCE+LnuB1Bvv2VsRMrjus33d LTKxN8D+6QjyIOeucjeWzPDxRio7seah7lesebw30+oyE87Ka0+0OW9XTIe6WwGHW02c JOZfENyDwA+mKO9QJ8DQASXwh5hM2STb6r67awE+Mg/jj5Id3zcno1Ec3L+ABnZfTAod 9N1rGAUUBFKrFqyKwubleIxrViQ5gz3okq32BeM6RAY5tIy5sGpDXvL4yu48VWaMVCr0 zmHktE+a+1ehHYbSB7tdQGJWhN/bvMT43dQJSss5DyjnrEwSrX/eCxMfUtGkeuvITQJy XJvg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=HBbVFcm7; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id u125si5203689qkb.312.2019.10.24.10.06.24 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 24 Oct 2019 10:06:24 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=HBbVFcm7; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:48284 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNgZ5-0000VM-Uw for patch@linaro.org; Thu, 24 Oct 2019 13:06:23 -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-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+patch=linaro.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(-) -- 2.20.1 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: 177578 Delivered-To: patch@linaro.org Received: by 2002:a92:409a:0:0:0:0:0 with SMTP id d26csp2477754ill; Thu, 24 Oct 2019 10:12:07 -0700 (PDT) X-Google-Smtp-Source: APXvYqyhslwwqT+W3+Lq9QmI48BqXUExO9/HHeW9hfH3XxDA34S03ySejLZV1TqKPBAi2k5OQaWN X-Received: by 2002:a05:620a:74b:: with SMTP id i11mr14625608qki.397.1571937127341; Thu, 24 Oct 2019 10:12:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571937127; cv=none; d=google.com; s=arc-20160816; b=nIkzkFIONowT7zTK3qHzHSrP5qOg/LYeRvJuirM9+1AbZKwsrnkQKFiV6UweNCRxLb XqG1ejWft7TDHcoyoz0aSx5UCl7NOEBt4R9cjHRvKPh/1XTnSn0300Ig279IVXaFcaUp o+IoYBcGK3lOXx46Y+wANQX//xBBabp24JB/uD62hDZrOA/XHqAMxQjQguddzw0fO9x/ Rk4zffLxSX/1Jin2yxMndQr9H4mTpFW86ZncUkhQcEF19lGyFPE1Ak/yBKt2YGOVS4Xg KBzjzqgwQ36RBE4qVW6iGk3Zn3+S2QFVT4VIWpwDxDUuT3qNsHH94AHNwdQqQkrYHcPO /OkQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=yfXT1kAIXINflleiLaCvqElRIW5XZjl76Cc6V+HbJs0=; b=mLbBfFOiaeivCGkyM+UOY926fsiaIl9wjT/U1oav3fggkwz5W4l6UWQ8/QFIb2wFan Mj6lHapLlwRBrCFeFb2h7Nb7I7x4MgU2vVwtVUnKdTv5ZrKjAWZWeJKEJu2i1MmlB0Pk 3t2/qNV8E3E9ib1XWWnW2RPKFzOH9HGdafmtdNZPNNYdS35RcQ5vRlEVZ7TooPplevoq 6GlQH1Nux4/JXUfvscB1Wxy1fhmkb0afukFxIdB3iJPyvMKplF/gWLGjVX+2e8KuAkO5 Eb1gelwm9vf7xgB12JN8tVL2poEoRwrYbsNA80MZpj1R8Uo7Q7LaaPgOlzjk2jVGCFvV Yv8w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=sz4rEsZC; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id k1si10345800qtp.232.2019.10.24.10.12.07 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 24 Oct 2019 10:12:07 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=sz4rEsZC; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:48394 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNgec-00056X-2C for patch@linaro.org; Thu, 24 Oct 2019 13:12:06 -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-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+patch=linaro.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(-) -- 2.20.1 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: 177566 Delivered-To: patch@linaro.org Received: by 2002:ac9:3c86:0:0:0:0:0 with SMTP id w6csp2421824ocf; Thu, 24 Oct 2019 09:59:47 -0700 (PDT) X-Google-Smtp-Source: APXvYqwQrOa3DDklVrIydbZ/rl9Wg6tdTzEp+i5zzgGSd0wNFpm2zo2+6YzRNkbTtFVhE0PWzk0E X-Received: by 2002:aa7:df0b:: with SMTP id c11mr44650954edy.101.1571936387699; Thu, 24 Oct 2019 09:59:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571936387; cv=none; d=google.com; s=arc-20160816; b=fSzT09mdbJuiUwn9wnD0Yaogrn+TsqgwTu2RgpuRUludmCSIwig4PzVvz4znYzqeWn mdcrVTPZeL6stAiq8KYNbX/itEO/k7rpbsejj9/B8wYYPhmY+d9hMRgBr1SFOi0SKw8l kbiX7nu18RKISeiuGDay0h86ETm4O+HwvliXmU3vL11l7L08Jf6EfOYneqy+jAFlyldy 9arYzntH89vOnIaZffvv7WtDBgasjdVE6cDFiEHMTNNvg3oOVobpKah+EfQR3GYXTOR9 OIN6pWaVWwMrsa5iwM3gTXC/+yymZHb4Q+GQQndpILDX5cZ0K4CDlU+e+m9TsGfY8E3q XfLA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=8v8h1OzrhCqLBFglLP5BbJjU1xr59SgzwhT/B4w8jqg=; b=PhR1+IoVyT18Dl/kfO/0rcBGaCeFi6dX9zQqo2QofPEycfNJMcjuh4Gwtw0nm5O7Ox n2aYGg7qVij+JcfMxkELzEZgccMAW79HtNNjxzCucnH5yXBDwVSGm5FWQDawf86pTpMV Kv4ZcZ5r1DBPrfARWlXutneRTrhF/1B2fYXf9t44WlkMMs5TShU6LFfFCpzzJqtMYBRv U8UC4/2g9S1i+k8omsacUnfany0X6y803g0c/5FA8JO0KmZXy0UvtQvPAQUMpNVannO6 xzmWXGB0Rpy9gol56XGDzs+VV7Q8ksbE629tZYaBDmRDZuFvZsbfev1aUWsAxPvNy6TM m2PQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=pdRulk7B; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id u18si15310144ejk.105.2019.10.24.09.59.47 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 24 Oct 2019 09:59:47 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=pdRulk7B; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:48168 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNgSg-0006PC-Bh for patch@linaro.org; Thu, 24 Oct 2019 12:59:46 -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-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+patch=linaro.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(-) -- 2.20.1 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: 177552 Delivered-To: patch@linaro.org Received: by 2002:ac9:3c86:0:0:0:0:0 with SMTP id w6csp2409437ocf; Thu, 24 Oct 2019 09:46:59 -0700 (PDT) X-Google-Smtp-Source: APXvYqyj9Pz5qcTNLC5W25Po3d8dpuL6gCo5KbwSxk/Ww3RCtDBRGpMgPh10E40s2dOZWYuySmue X-Received: by 2002:a0c:e70b:: with SMTP id d11mr2752909qvn.51.1571935619449; Thu, 24 Oct 2019 09:46:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571935619; cv=none; d=google.com; s=arc-20160816; b=qjabFvVEFBTfCXXJmAMHK08DCcOSfjlPoJ4yN+JAOsR2poIhbgt5FgT7XxSDRhki7z 1qrR1LRB6jVpnrY02pmdBExmVDPIFVfDvTVGRI8GL7kxVWqj2vCBCVyZqBSTrkzNcbq7 S1Z03L7HNi9HDnEPxP1pr5dSfNsaDBBU1/P6TYyZ0Q9falnp5F3WMAXtJVxU6EpnBB6j qT0JVZJk9d343T1O7F2hq3FwT+dd+LpI+jGLmCtmLnYmfsJkFOa5FU0K9LkyWahO2PZh dku9UMeagm6jhpQ1XF3iRrEGdr8ZTnpmygOONaUnWdOjpIJcQlVhABFY2PRryNTg65G8 QrGg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=BZJHPhd7AksEx+H4Cy3rMhdQWffeBwbM7nZoccEAv4g=; b=M8Tk8cbbWDtGBoEjVAY1BZboVIfdg42VxsJhsBYWIiuEsxF31W1u/ioNYB3i92vSbB wMlPlN5jBkYYCAhcP7I5+/FUhPPe0zSa+Gx8Q/UUQ/va9wgxgfd0GzaK/zzripbB5Dmy jvx4VRPisHFfoVi6jZwTEenZypV1RyDBuN/vspqtJEXQdlnxlEZSu8KujU3r4RnunZHF XSzzISPucoH1ioiX0qWjONJmMdVYE4qlIvRzpvxnQG6Q6gayttoE46lZYm2xSSGq9Hip cUeLhrCZUZtLRVoGHOyWvez9/sOzqhMlYsptTtnJFnbymVsF1ZkeWTq+QWSEgrq9Nyw3 V4rg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=RQXhPimm; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id z34si24555695qtd.120.2019.10.24.09.46.59 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 24 Oct 2019 09:46:59 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=RQXhPimm; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:47856 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNgGI-0000Ty-C9 for patch@linaro.org; Thu, 24 Oct 2019 12:46:58 -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-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+patch=linaro.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(-) -- 2.20.1 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: 177573 Delivered-To: patch@linaro.org Received: by 2002:a92:409a:0:0:0:0:0 with SMTP id d26csp2470931ill; Thu, 24 Oct 2019 10:06:30 -0700 (PDT) X-Google-Smtp-Source: APXvYqx3bJp80xOwCZoqAbBE0Ca8Fji9s0C34CnPldnHT6m0b4Q6ljgp8vcZC+jgy3dMriiP0kR6 X-Received: by 2002:a17:906:5399:: with SMTP id g25mr23757819ejo.125.1571936789849; Thu, 24 Oct 2019 10:06:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571936789; cv=none; d=google.com; s=arc-20160816; b=REfP8XC/rL4NypEgEVafGaG+DvOnAwCigxfJibBp+DRQkMZILr4fqz/EAzEibNYqXq DfkwAz/64a5dOZIhxMRuGY/a8ioDq+3Yv9CWyAJmqpN/RgkOnFTAfm6TkIX9O7TgnaXZ 08GmgTe/hBI4Qi0bsoBIP8OnR88I7cE9M3mi7xgGuAWbTU3GVChcR33SvWiJf8VoMsYi nX5vL5DTI3MCPChuOePBJkEUJ/ccMwOg+NHATkI8BwawlG6Wwz9EXbKqWvB1W7vY2ftP lTrt0aVAmNR5VMwTuBqySM2w0V1PTH++u2Bg5oXkm/dHfC0dSIfMWsYQA5MdsLn43Omd 2uIg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=QUTF96nfti+DI0q+OP0hhjq9ZudXZCCZu7o5L2KL3Xc=; b=cA+vYn0ej9GwVGKXUfRCBYKXTVSsJBMf9JdNtjJs2NuxfPxQ2y766w1UtE/iUu2mE0 I+PhcqbZJWQ+3WSigDmCj7TPrQPcYOe1KWPzHF31GCYE4HJE/Enl+7Kg11tlkrqhbz2V 4QicLXV1RNHe9ZUtUDLb7zMXj7u2a5lDdb42nn2iCAqsb7UTJ+W8ewNNwn4YQEli4MYi oJGNcrmwQjT+/SMV/XRcW5kuFHjllfUn0fdLrU/tj/7wMH+w177+g2roji/KHF/dqVCD oxgZjHmC1GBLFSCBGXreiE0vbRjv1SeNsdgQ9X7fS97CLqnAKFqJIDzCoMnokqMeyUH3 w16A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=CgF4v0w7; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id b4si20092896edk.331.2019.10.24.10.06.29 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 24 Oct 2019 10:06:29 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=CgF4v0w7; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:48292 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNgZA-0000ei-8o for patch@linaro.org; Thu, 24 Oct 2019 13:06:28 -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-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+patch=linaro.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(+) -- 2.20.1 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: 177569 Delivered-To: patch@linaro.org Received: by 2002:a92:409a:0:0:0:0:0 with SMTP id d26csp2467402ill; Thu, 24 Oct 2019 10:03:51 -0700 (PDT) X-Google-Smtp-Source: APXvYqzpGjuP8VcVR/0AYKc+76zA2DSQqtX3IQeftJWuVYwq/2ajzLe6i760Adt60jrzV3MdDb9M X-Received: by 2002:a50:ac1c:: with SMTP id v28mr2862560edc.156.1571936631868; Thu, 24 Oct 2019 10:03:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571936631; cv=none; d=google.com; s=arc-20160816; b=GQtYs76bANqROxLSxlM/P8f4/MAYbJSRlk97mGUEeCaya2IXhMMwHEdpOUIHj5ZXVZ 4q2kX6uCEg0HdpSz30Ue+296WnlWe5+z+E3mHEeBJOfLUkyAtxCrqcp7U3CHD2c4I90d OobHYvlYbivqZDOVkCc3lepKPwoXvPC/Lx6kVPRnUyCdw4aXAAD3JwebZpA6fbjwEgoz efTRKemXSEVZ/ghf1yjGZBBADimU64iFIQdIABT10n6VydAWPL6zIMjXxW8Nb6+1vrLg +p0W2BcTFhyCyJ53IkCi8MdMB1Er0PI6hPEnmmgOAaSn4fcuOKXM4G2TLk9oeG4Epu+y 4XNg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=IVPjk80/vMxw/zuAjIrvBHIged7KPUhTphMMQkeon5g=; b=UbnId2ABtlXFtOzDPY5XkNGJIyIezryZZrctPRGDdMi8ntdv5GOFJ+wu9r9S+l5hZL qmzEStpDWZh+rR9Eahy3WJ0D/1o98c6KgcKpD+bBg3AUAASQXVQvjqBomEs56F/VbDkr hFYHnrfZNtE18uKlP550waRT8jD3R/JYVrWQB4e6EJgh5mP209iWF091VJVNEz45nVfH ydjhIeQvvaeCNqdA5WhSnMXlUnm+0VlD8Zu2XcvpNREAp5FnJDub+KxLh4jkSfph5q1M /aF0b7q2JI4Briy9LADb9BwhIIfW5dCrjlwapzTs73fpi6AVOAUMSX0H8DQpRGIMAXrk V0rw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=CSLUh47a; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id a24si7914947eda.446.2019.10.24.10.03.51 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 24 Oct 2019 10:03:51 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=CSLUh47a; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:48236 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNgWc-00032n-31 for patch@linaro.org; Thu, 24 Oct 2019 13:03:50 -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-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+patch=linaro.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(+) -- 2.20.1 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: 177553 Delivered-To: patch@linaro.org Received: by 2002:ac9:3c86:0:0:0:0:0 with SMTP id w6csp2410395ocf; Thu, 24 Oct 2019 09:47:58 -0700 (PDT) X-Google-Smtp-Source: APXvYqzqH3G2gLbSnOL+6GDhT9RtLWDTXwIptisdaURRx0m1l5h4+Crau/5ywFUJ0U0mMY6Af/gw X-Received: by 2002:ac8:27b7:: with SMTP id w52mr2513553qtw.78.1571935678527; Thu, 24 Oct 2019 09:47:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571935678; cv=none; d=google.com; s=arc-20160816; b=ulm2GzA32T8LGYN0L+brplwR9Q9xi2EbXqZ6kt9B+rvzRkv/W/Fg6PAwjAZvWZSyEY PrT4DbBZ4L3PMLRG4FTIJfbU7g6uE6ZVaSRQOAWtThOOkPhb3A1sf3l9NuDPtD1tAJeZ Dpmao8SnwSEksnjFkiL5v+ME8gsdjdEyBxu+DyrQmq6Hn7t+0McYVQ2BqsVSsybhEJVT M8V5bidsMkzazhmDba9Xuowmq0gSY9VVfN4SqZ63dR194gxN+3a8j+a7b546aidlAZyT tZ8ZKSaNIYazcCyz1X8rIJSKAMVFgTdImYvrGn8qOW9NvGmFwBcKyNZItnNeT9Fb8sZK KWsw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=OcDwolq811QfFGrcusum3clsrtTFTFlEcKsQCy0b1II=; b=1Iq2ALh2jR3rTekixCJyWymMXnz9EuMcutqqpX/D/kPDVBLr9/4eTWRIc1JAVU7xG3 iTMwWUECMuNUPmKKzH10gEUNwLnCMBSw/23gKNsyW2H5EuxuwVh07XJmWs8IRUctTjPw DSvd4nN5uWdTKoc5tPEHnama10VsDOc8IkeS4+djUz1191H45jkOztJrDBo6di5piZ5q 0BQT+pOufhgyBofBoc/KVTcpZKMcbM+Sx998VTg8XIhVspAMp5xoed323l8oFjNT+34U V1ndr8Why8a0UxvHafgOFQmpJDmBtewStKyoyAfqrXq/g8uW3LZ3em/wNvaqawwq4wsR sqXg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=CWKNZRu5; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id o38si19773387qve.161.2019.10.24.09.47.58 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 24 Oct 2019 09:47:58 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=CWKNZRu5; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:47888 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNgHF-0000hn-8H for patch@linaro.org; Thu, 24 Oct 2019 12:47:57 -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-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+patch=linaro.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(-) -- 2.20.1 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: 177555 Delivered-To: patch@linaro.org Received: by 2002:ac9:3c86:0:0:0:0:0 with SMTP id w6csp2413538ocf; Thu, 24 Oct 2019 09:51:24 -0700 (PDT) X-Google-Smtp-Source: APXvYqz1COf7QI6z7Vqs24FQy97nlNdF0573iFJTHMJLD0Iyuwyu15QhSrEx6HPawvsh5gS5PoFx X-Received: by 2002:a50:eb42:: with SMTP id z2mr44291759edp.291.1571935883890; Thu, 24 Oct 2019 09:51:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571935883; cv=none; d=google.com; s=arc-20160816; b=x4rSbl8906+ddxlT7B5oRY3AjXejp+RHiUXLgtZW8g/02g9DA4fO01g5S6gvpBh9Uo ab1ALY5TGFVKsm3PfgCRt0iOYwrtTvCcZnJz4u5JC/QHpk38Zzq4RZIJLiIvUXZ1vzE4 /UE/QLVYSHybiuxEyDGObLmxvErWwfNb1/PFJOujbxtZJw0Hf+KK+EKijBJ8iy1Fxh6p vSp3Lt/xDzwYw4I6VWfJxlZmFdqQg2AFGBlPYWeYjGwI2oN1jaRM1SNEA/oYd3d+hr7P wy55vs3KZED9BelmJAEPH3Gt6Fo/bLQ+uQ3XLYGEeQhW7QQjXwER4qW11AVmBzTr39k5 6TGQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=XZeplV9UvaCL/Xmc97dVbloX+PjjbYg7Xk7yU5JEklc=; b=NjoZ45AF92lj/gWRm6vZzZSog7csbfliX0yjB9iBr8Pp3rRznMTdwaIz6Q2uPkYRBQ 5pBvx8poiuAXpRUkn+i1noMCf/W7RUpfbMBcRT2wF3PeTM2Uro+z/pvhx0Lx+N23gGmK Yd5R06c56hni1VINUklHUxLk/KBGUO4kRgIyr9pgMqcVoC7Pmc54mMSxyH03B2V9mCQx j+t/m01v6FlVE9kxjzGA/sGGC+gmqggiFX80ZAWmK0qDZORA26rz86jKCQW5Yuvz9+IR 697b5bhd13Hrw2MrstP6bHjjKiJdNVTmw36AYQSvji3mh/mlMfRmHYEDA65JgyQlcy4X l2Cg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=UmIp1ToZ; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id x25si7013154ejb.284.2019.10.24.09.51.23 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 24 Oct 2019 09:51:23 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=UmIp1ToZ; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:47994 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNgKX-0008Tk-GJ for patch@linaro.org; Thu, 24 Oct 2019 12:51:21 -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-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+patch=linaro.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(+) -- 2.20.1 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: 177558 Delivered-To: patch@linaro.org Received: by 2002:ac9:3c86:0:0:0:0:0 with SMTP id w6csp2416725ocf; Thu, 24 Oct 2019 09:54:24 -0700 (PDT) X-Google-Smtp-Source: APXvYqyVs4nCfol54dnn81yPphrIZ07I2gZiE+TBxDSz5zhMZr9jni/OcIW3d59gaR1l6245VD/L X-Received: by 2002:a17:906:2cca:: with SMTP id r10mr39583928ejr.108.1571936064653; Thu, 24 Oct 2019 09:54:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571936064; cv=none; d=google.com; s=arc-20160816; b=zYwBIvgw9/mCmi6qALLkDiVHwu4O7Asz2i3K6jP2jcTzysI5yLLbNhNNwtU2AZnM1m SfLyhsC4e83mcUpxfRJXTYhc+tm4Z5hzxH5LjOdQMnI/xuI3QhHswqpArbwh1Txd4yhx 09acXaaxaEjnTnpN+cK9gwTyQNQGfBHJArtPlcLzNlNBBOU/RYyeDvlX3duvCjgeq5wX 0/ePM2BibdsTb0qsqI6tf8GLii6ZEStW5RQ0l9Ed2ViucmUOkxQyMGT0fuNfVkOrZJdZ yTSmlu2cHJJ/8sYqNrnOAPggPp+YdNrhhQRivVN0UDYAuP38YS3+ffdhlRM+OHH7P/hH 5sFA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=WFUwsZ8ugMBSw4ZJiorvJWtT/rnVZy1+6h/U7Ubz84I=; b=unLJfes0ah1Do0iPvJqI0ae748VlycvlEmu7f1cmvET7kZMUoNk4CLnNIn4F/bH8gx ajx1TJfhRc4AVSq98fiT5j6i8Q/VT8LbkIjqXJYqzD48ixLx/7xgvvPu4QyY+dvhGA6Z lIyxyxAwVLdS/aJemNANnDI+Fjv/IPBYhTj+rLL72H9A1b120DDF2jsyowAZjqmy5Ht2 lzOcXPVNg/8jzv8LcnlBuKua2kUSepACf64a/NsUFjYBFyhYW7TgUHpC13qXan0Y0Tc2 6WACZ7O9MQP3SB6PqAzHBPTal43+plE5wPRWqDrE75XC1Aq0WdMKs/4SW4fvsSb6FFmK bNPw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=FvlpS+bp; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id h34si18291106ede.247.2019.10.24.09.54.24 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 24 Oct 2019 09:54:24 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=FvlpS+bp; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:48064 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNgNT-00052T-1N for patch@linaro.org; Thu, 24 Oct 2019 12:54:23 -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-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+patch=linaro.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(+) -- 2.20.1 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: 177561 Delivered-To: patch@linaro.org Received: by 2002:ac9:3c86:0:0:0:0:0 with SMTP id w6csp2419992ocf; Thu, 24 Oct 2019 09:57:55 -0700 (PDT) X-Google-Smtp-Source: APXvYqxOGRBnW2P1WTzRMv2GoAXn6OXEPjDiyrHg99AEvF+nagHVuB1eVMUiZmZ9g3J5hRHl+RtE X-Received: by 2002:a05:6402:1454:: with SMTP id d20mr45943964edx.53.1571936275498; Thu, 24 Oct 2019 09:57:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571936275; cv=none; d=google.com; s=arc-20160816; b=F2tVuxl6j0d0Pl7zQBsaM9EC2f6fuQrt8V+jJJWr2IIFSPezJLjMvDTf2lChCvLHY2 TiDT99KArpDtRWwlBSGKhqxm9/IwYHjgD4hQ1z3M7ueUyjeQgoIr8HnGY72cb8+qaXgs ddKqFdRKQTvsxFPYrIqbRB7KEVCG/PFacoQxau6uD4SfHjM3TO2Uszn1yY8TjDjlpsmw aKOBsrTAt5sIkQPnfpyDU6km3a832Zpf09ebu0RmuTmFINHYRE6cENrSvbkm/fnS9RYY 6K86qs0Ini6QfI/9bk+iGlmj6PAhR9t989XRK9Blm0GGT59dx3k3ixuKHGL7PX6fWJr/ WXkw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=9fEeMZ9uPtcAifoblXjrkL5Kbv7QSQTtSjC/i1CHC68=; b=OzaB4LgCEM2L1klxbzyltVtWj0uUUztYuXzdJdAIhJuO053V3ssZINcCzg2CNwuBoE 2whDVJqX4lajxqQfMIa/0VTc1k0pyNHa1P7ddQ5PKVRWp4S8Gsj31C4Uv7tH4ReAC832 sdaNL0so1y0FK3uMuTUCQ4f8QeNCJOAhu+zwD036ynPjMdrehEc8c7AiLCVblz5GUqcc rQuopt29NnR4YBr8W/UiKP0+B8Wu9xHfIry8Ca65zG1/zhiPBeDpubuwYqHAD0W43Jf4 n5pN4XzWvj7JbyY8dmAK532asgga04q8na49y45APqj0ShYPUOpl3kYKwV33IzHc/c9Q yAfQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=dFin8SZe; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id a3si9906344ejy.286.2019.10.24.09.57.55 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 24 Oct 2019 09:57:55 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=dFin8SZe; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:48132 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNgQs-0002wu-3H for patch@linaro.org; Thu, 24 Oct 2019 12:57:54 -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-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+patch=linaro.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(-) -- 2.20.1 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: 177570 Delivered-To: patch@linaro.org Received: by 2002:a92:409a:0:0:0:0:0 with SMTP id d26csp2468062ill; Thu, 24 Oct 2019 10:04:19 -0700 (PDT) X-Google-Smtp-Source: APXvYqyqcEZdB+iMtTjqS7RnjX5d8jbCscHc4XXG7GmOdwOyUZcUUki0OrH+9RXfkzDA4QK8+iAX X-Received: by 2002:a17:906:1f44:: with SMTP id d4mr38255649ejk.16.1571936659511; Thu, 24 Oct 2019 10:04:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571936659; cv=none; d=google.com; s=arc-20160816; b=Q4lTqVqDvytc5rg4wI/bzzZNVx7t2/cyUqRAIiHl21z1Gu4Hxl0dOJGyqiUpK0n33k tcTNSrlSwYf8fy8q87WeZFgnH0S58tKUW110yBQHMveWz0G5IewrbGyMWU5W8m3rcC9o KdUhda6wmTQ7M1iFWxMYLq/gbFFXTUmZZZozPR13eJIU3shVgHx+D68JTwwBLWUs3qbE mBddvQ8qo0goO0sJdC31+0dDRKqHL0J+aJhWjr1L/QDcPZVWjR4sNdqNxAJow366YpMV 2dWQzfqrLNHgsjyNCQbZDsesULjS7RkfXKsPRoBbyHiZZdhmH05HiB3on5Xj7Nx6Xu2Q qwxQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=AY2/tIXkLZV7yrWE3pOZo6OjdcTvWP16EPP+NMcPWOY=; b=QAWxllBxO90+qDIYUEoauqIu+qmplb8Ig4OJDlY07Esgsn+rYAtQszgBVisVzfOOst WtbWUPW3i4QlF4ohEczrajmT3FCg1e1olCrCF8xfePkg9Mli27ZA1XR0gYKPYhnP+shO 424RPrjhGFaryUiXbVqI+0IrELxNJl7MwYHDmM8+5QD0UjZjLFqA/pIQpX5qrTOAQG1d Y6skeifEZzx7bu0qhWq50r/uWwah40sP9QkE0SIUMhYm8c1Td9fEV/y72u54N2lFWjig J+KMarMHbmcSBx2ZG2PCAhlR3dFQffpmL50v2KZCCBggDzMTo2X3WNegHAGk7d6SCdfW FmUA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=rcKcYb4Q; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id f12si9025729edc.1.2019.10.24.10.04.19 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 24 Oct 2019 10:04:19 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=rcKcYb4Q; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:48248 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNgX3-0005Gr-MM for patch@linaro.org; Thu, 24 Oct 2019 13:04:17 -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-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+patch=linaro.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(-) -- 2.20.1 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: 177565 Delivered-To: patch@linaro.org Received: by 2002:ac9:3c86:0:0:0:0:0 with SMTP id w6csp2421458ocf; Thu, 24 Oct 2019 09:59:24 -0700 (PDT) X-Google-Smtp-Source: APXvYqzev1gN7QKGXQFfq2rR+mqOJIJ3RZSjATRffAyFd94oe3LB0s4H4eKHvjypZk6DVAMTxV3S X-Received: by 2002:ac8:ac4:: with SMTP id g4mr5201975qti.326.1571936364194; Thu, 24 Oct 2019 09:59:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571936364; cv=none; d=google.com; s=arc-20160816; b=mLMdCW0SQBc7l7NFQLjQD4QEl05pVhGtDDt6LtX2U3IbaadS1gmIuwD2U//y7B/rhe fzLItnR/YxuV4R77BmjY1U4CHzASYrLoToEEwIp3EzGV0xfZ0uZDSQ7S27y5DU7+XwEK 7lpWkgmoY1PTp8N25x+XVtnOYWdH/EYr/hLodNwkYlnMbqn9j/gL4cOMFdLqipFjpUi4 GH0NEuBmWLjQKiAHYwRjgkc37VCIgw9EUK4RCJbE4cUHTpGfi4jwWkr+9yHFZkaSbL5r Ga8mW/l97OpfhLXOqG5opVZSmrSQB1HOXJZR64cdpG4i/xledYnTEwx+Gb/uvVyVOg7M y/vQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=hoD3aqwz/kF2U/X48pwyEPkA/UK/DENbEy2Cn4bAuH4=; b=T3XBIlwcIxn0cfZHl0oAI+4RxasFOj1Lwlq0SuDw47ubRWSfZpOASm5fdkYmzyJpB0 cjBispVUaG5dEtNQL0lT0Ejt53ylzW+/N2JurA6s3Swz+j5dQB67pRQ9DDjGTpHtR0yE kICm87uPFLRSKd/9vmyIH1wljHcJcTuiUCe9iRimVUwHBIsnBS8fUGFS3urOzFuDn5W6 EibJQ6kJVNLySiI4KhZmVlW4YW6ShHIFYcYZsd+zh32mQ6c39QU9Hn3Vdq/qE2+iZF9x rvjiVB86dOHHFBn+/k1MPjsH0ocLaRl11kmFF8B3ZRmRC/3NbOGNnlpwGzWUZBPOu7n0 ssHg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=GGNv6wHw; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id m5si10587299qtb.134.2019.10.24.09.59.24 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 24 Oct 2019 09:59:24 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=GGNv6wHw; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:48162 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNgSJ-0006Ez-3f for patch@linaro.org; Thu, 24 Oct 2019 12:59:23 -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-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+patch=linaro.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(+) -- 2.20.1 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: 177579 Delivered-To: patch@linaro.org Received: by 2002:a92:409a:0:0:0:0:0 with SMTP id d26csp2478274ill; Thu, 24 Oct 2019 10:12:35 -0700 (PDT) X-Google-Smtp-Source: APXvYqxvAZdzDtkDuAGms/YfjYKlwBDiDL+q4jTqTH6V0Ed416/ER/VDQzxAVrQ9oWdHPogTUWrk X-Received: by 2002:a17:906:eda2:: with SMTP id sa2mr4393679ejb.14.1571937154868; Thu, 24 Oct 2019 10:12:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571937154; cv=none; d=google.com; s=arc-20160816; b=ZdKbwSyNDGQ7PsqeSQcoA2z4TpsWcAhn3RAWa5iUHOFGKKyNToM/C83ZOFoKZIhdv3 hGeI9rDDwwtHZpCJxdcXor3kwJPe1wII7ZLJB0n22pKmQRrwdTY6NijczT6NSs3lUHRw lKk4Og5MqkAWPsP44SLa2VUcy8cjCFzR/tPhwJdVH1MRk1sHb9siAkS+b7Bn0rPSkrKL I1mYHy82mWSIBzcbqR19KjW7oyYtkl9CvsURYNJkSNGcmCMpiZajt6LCx+vBewlz5P4A r5tks7EKepxiUHm7MPR8rYkJ3ptC366zOWVO6gzBsl+Lu9AGNOwaFWUoX1qcD3o2AohE enFw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=acyYv45nXPHhkUzRU5weWk65uHswNK+60vD7SN3aiY4=; b=kbhARcTPGxVgiAF9lqpzorIAVcVn4GY62A1cjnwRhSo2c7CHaRbhWEFoWo6CBCOn7y 2BhRbC2z0NDzBFOBBTl/yiCkG5Px89AvB3sysRCwOvrZQVSXT7DcvQ7iymiWoqOtvUXK bKAgEAmkQrq82KOvDDLRxaVeHXMx8zoQzwY7+9OmNG08uSPyDXhhxBHOYQ1APazD3RtX U9bFRL39FYapAv2M6gYnxLvpc/o6iNe7q7i4xB52xaOMRAh2A2IvKGJc2A+qYaBA/PkT jSxjI51oNxUfiX45Ui2XdyfS2qUwYTteUYJNvdi6tQNpNv5GwG/4nQ0A38b3tB5GUj74 xsmA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=TmwUmvea; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id v13si16112462edy.441.2019.10.24.10.12.34 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 24 Oct 2019 10:12:34 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=TmwUmvea; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:48404 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNgf2-0005Qo-Hj for patch@linaro.org; Thu, 24 Oct 2019 13:12:32 -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-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+patch=linaro.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(+) -- 2.20.1 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: 177567 Delivered-To: patch@linaro.org Received: by 2002:ac9:3c86:0:0:0:0:0 with SMTP id w6csp2421920ocf; Thu, 24 Oct 2019 09:59:53 -0700 (PDT) X-Google-Smtp-Source: APXvYqynWUeQjJXrKxzaihuZGo1zssMdeGvENE9QEUQaPjIH4eeRkszKXNpcmtoz6t5tnoPlL6Lh X-Received: by 2002:a17:906:55d1:: with SMTP id z17mr38765661ejp.300.1571936393745; Thu, 24 Oct 2019 09:59:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571936393; cv=none; d=google.com; s=arc-20160816; b=hGi35VFRvRJuiaz5zyB2BXvQhnu69P49dGZmtOaW96PekvIVA++vA1RooKGphqkQqG gzDTo+0aW2QyC/1oVSI19rtMm606Pw5+oUgDKBLSrR6s3RcmGOwAE//VKuY1sa4VgkUa gx0VyLbkuoTLOunJGSWdJjWmrf0gAlW5dwK8EVW08DZKtNwgle6bdc6dlRDZcW02NgCH OebbuSFZrPmQZL31J5+Elrhm3090YWDp7JbyKLjuLeRPInm4pC37F/IFZNX4BxdosOAX JLLQnU88qnKFuIfaTNKUCkAWktzUcsvZukYwLmDGTHXNyYgrFnhHLdMEvMR7TUgKsPmH BPYg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=EcerNk3YeDT5sQSP3taUcz8aA1kUh9D2O9nEmkTp88Q=; b=ShaB/AQccqv1c1Lffe7Vzq2B7UrGY0ghbdXM1p2e70ka+rPbdtH+UvplGOYq2FegEA 6DwY7N++Avu7HUyWyc6zads6dXDmMqINK+2i2D+hmaW/IAVL7oLFfUvPaaQ3Z+mCOoSe QMG0IsRQf1TgVWDI7aKSJbNjOAslVyXQkVMTvC8Dz5gB9LHGWYSdzWibNRuvL3OEousM gZC3bfd4wxrKGbbxmcwnlCmN3Gn1FLzmBcWY/lXZVTUWW1JRue31URUdHVGYphbOQcwn cNZUkSIkuZ0Ejc0Gmx/PX+unK5EYAPqZ0/wmouA3j9/RCSB5gox0t56qz0nXJQBI07AZ iY2w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=L2PlupZG; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id jz12si14848738ejb.193.2019.10.24.09.59.53 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 24 Oct 2019 09:59:53 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=L2PlupZG; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:48172 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNgSm-0006SF-5a for patch@linaro.org; Thu, 24 Oct 2019 12:59:52 -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-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+patch=linaro.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(-) -- 2.20.1 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: 177574 Delivered-To: patch@linaro.org Received: by 2002:a92:409a:0:0:0:0:0 with SMTP id d26csp2471504ill; Thu, 24 Oct 2019 10:06:59 -0700 (PDT) X-Google-Smtp-Source: APXvYqyfSqqJ4kCPkAkhNSLi9oQw34YvcSASGnbkUF9yves8/CmuBTzItYpIqa5twiXCaWQwlWTQ X-Received: by 2002:a17:906:f252:: with SMTP id gy18mr14874000ejb.224.1571936819162; Thu, 24 Oct 2019 10:06:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571936819; cv=none; d=google.com; s=arc-20160816; b=KT/U0DbCBG0IvNaaIlQXKd6cZLpBC8Ma5GoqG4ZJ1uXZ9wdKfbY/eLjYh/GgUrXuYa rhby23jd/cXcQatnWQV0FTitJPW7ECiuXj1Qry9j/WSi9nksOoj0VSDD+FJi5SOktd6C PgUPWultiYBpAhikrGn5xVoLNiDfwzz/MjUo4zTwX8blTHF4uiYEZ/XajXvOyoI1VcUk CrjRVsPXjtxOr7ADhSAwhl46NW1M4C0c5h7Zlqf7sVa1bywC2Yoma2uIxpQTtkaG9+/w WG9wBXlsVhm5iRO7uVloIjJE2jZP+umlJEAWPdneZmFA+Mao4JYWaIHHJRKV46WWD1CO TGmA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=uYiMMG2g4SkvD83lkxSsHqqS6mTu3zs23wVOsym/Wvk=; b=RaRw9XUlgHxtlBtTcI4lDUuH9ZjYrpLup5VrqAQ97jK3yBlSoCyZ+l2LjOyD0FzcwV mC7l1tlC0t+jhDHXYDDNh+X40OeZnZPUhT804E6/1Lv7zJ4qJxbW6Rqdx8TZxbClCbV1 Thc4YUjhsO+VFZxBwJVGvmJbFY3VMSmEvnJ5jGvHTA9Pudo/0fl5F9qS7DFrfDlI1TqZ uJ3FvkUG2gjZzXf48e/+bl8LHVr/X9nZseFTZzYG0jjjT7WZ3ylYz34OFosmcGRbWxeO W4ugPuNbru2kCW2eYyO9mfUV1bG4aewqdSFWniBoTZ3fTv2jLLGw3HUPzkxErjME5+cO gjIg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=YGAt38FM; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id j12si12667042ede.121.2019.10.24.10.06.59 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 24 Oct 2019 10:06:59 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=YGAt38FM; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:48310 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNgZc-0002LH-NW for patch@linaro.org; Thu, 24 Oct 2019 13:06:56 -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-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+patch=linaro.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(-) -- 2.20.1 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: 177584 Delivered-To: patch@linaro.org Received: by 2002:a92:409a:0:0:0:0:0 with SMTP id d26csp2482981ill; Thu, 24 Oct 2019 10:16:35 -0700 (PDT) X-Google-Smtp-Source: APXvYqyPL17Ctg5p+PyFJobCveM3AS3VnrZ5DmKD1pXDL4knZFI2Ce5caijXEjYIigVmMlbdrqqv X-Received: by 2002:a05:620a:2158:: with SMTP id m24mr15141223qkm.250.1571937394890; Thu, 24 Oct 2019 10:16:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571937394; cv=none; d=google.com; s=arc-20160816; b=PCgoHtZ6j0GO9pGqbwRAEgsANF46MO6UdlTLgBTnVEC4+fyELu05JhcITu59G9zgtK 2XtyG4Nbgnv52CAI2vqziVc4rOu11v4qQknjRusce8ewdHtk1h2h4hYFgnC+WiPAfNJq 5uxv6zL6rP+DiDsMCHIPKIp8k5VP9+1lzwzCXYneqYSqFAf8GrjMsdBNkQcG+fPz/pkH kG9o7/KppKVi7FKdAwPVKXX0Wz7du3fkbooE30dPa9KInMy3deDOw4LDTpUry5z7pqeV DnaZnpWb/RcD+5UcVaQ79qSZdI2yzHPwSiNk/v3IvL8fqlZa26uaV27PVGshHxHsEg8/ fBTw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=bZdsncuNDnJQ9EFbxxKEYZAYg/nM+O7WLjtwwmpCRgA=; b=wpLf1NBLXVoeJGguM6HWWfklAWl3B6kJtW+EcAdUT8XyZkceFUERD+ZSjAr5xgMwD+ cyPIhXN8iBe2/X1IJPlKxj4D69OLUZ0SvueOX4ACnGw3NyE0VgH7rfy21WvZ2i5zDm+4 V3m/LIbIJu2ZLo+CZHFOeG41Sl8L9a2O+WYwgFLl3hV/W4dEvz2CmsPvUlpXm2fl0GkW I3jtxLrZzrjhv33JCz9l6xaYxHG+zYCIMpDpzBM84EHEvwk73xJ15d9a1b4cBoPV01QO pKmMTCzhzjiJCox8S0zplDSaouCiArhxQRzOmx/EDzO8ROgEAfB80HpD/JBCKy0RUwnU GgOw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=tmCbLpdv; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id i2si22051429qtp.398.2019.10.24.10.16.34 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 24 Oct 2019 10:16:34 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=tmCbLpdv; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:48500 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNgiv-0004nD-JI for patch@linaro.org; Thu, 24 Oct 2019 13:16:33 -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-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+patch=linaro.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(-) -- 2.20.1 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: 177571 Delivered-To: patch@linaro.org Received: by 2002:a92:409a:0:0:0:0:0 with SMTP id d26csp2470564ill; Thu, 24 Oct 2019 10:06:11 -0700 (PDT) X-Google-Smtp-Source: APXvYqzt3Cq7O5/iRd5lyuFJIVlOh42ZMMYaIntv9TsNoG0yHaQEpQLmX1zbCJqcgmSCWrt2MKk0 X-Received: by 2002:ac8:4697:: with SMTP id g23mr5160039qto.74.1571936771717; Thu, 24 Oct 2019 10:06:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571936771; cv=none; d=google.com; s=arc-20160816; b=sxoSB7KDSFyHVXDA3tlBhnsYfCo2cDDv++MjNtNs36e1LXVqObou9spFnMPcYKOvFn PZaK+zzC/D571DmnaWMp9H5zPqVDkoipUAr5qk5wkBPGgL4O24Dp3/5Ayew97kJkVs/G gv/nBiwEJOxbciuGhc6GjddmFEXy3S5w+XYEWuGw6GLB+zyZ751Rf/E8xtQOfNTnZM1L S70jDhVme8R9wxhnN9bH6LTzt9Tf+Ao32jYbO0pZtfjf8VM7hWImpmdGrIvif1+wlv2u Q5meSyYb6FkAEg36RGWxbyVWnb8D1GUqUS+Hltb45/SxjlqLaTMmstw1Xe4q1pA6rVIq WB6Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=WzfboK1OQbmWS+2qtK+sgT8HKfmWZJQr5eBbFKdwmAk=; b=QMwUWj42DZjh+HxoygJzMUNrYJoDmNaXBhsHlvtJsFafYIfk3ZL+XM7cgCUUj9prvK X+DqGr8WaHuirVMYnNeiqdgVNXjY0avuK87DdxxVZaTADRCt5DHRB5lekyyewOumNKNe NaufrFe/BD7OkrrPmQ031liA1gfrHQj+LRMazisA3ADmBLWqlVd12G2t8wpF907y7BeP f2vObFW1PouEBW+tHWeXRl/waR5bgmZu/se6lGtYaBXu2hq8g5xYkSkZZrulqObIpjNT D9D3/mHfemJomkdI+xk0wbDpo9MKfGZUaumGgwOlv37r2S1uu0GXcuaOmL459V6As0vC 0SzQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ObZ5vpZH; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id m16si12717027qvi.202.2019.10.24.10.06.11 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 24 Oct 2019 10:06:11 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ObZ5vpZH; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:48288 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNgYs-0000dL-Ef for patch@linaro.org; Thu, 24 Oct 2019 13:06:10 -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-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+patch=linaro.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(-) -- 2.20.1 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: 177588 Delivered-To: patch@linaro.org Received: by 2002:a92:409a:0:0:0:0:0 with SMTP id d26csp2486982ill; Thu, 24 Oct 2019 10:20:03 -0700 (PDT) X-Google-Smtp-Source: APXvYqyIl8TMxTyeg1O8Crm82l/gojJN+evUhhonDvW2VY1F4LWJNOqULee/o0t4qlEIamCPsB82 X-Received: by 2002:a05:620a:89d:: with SMTP id b29mr15226786qka.266.1571937603222; Thu, 24 Oct 2019 10:20:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571937603; cv=none; d=google.com; s=arc-20160816; b=dMsPoqorlV3vxTmC/ZqgHGydWTAp4IYaqh87xe59ZsVAx8k1hnMLCyixNdaovuwuH/ MieYthNPVhJZ3ujaZwHrG6VRHg4oFr3vZro1xM0/Jnr7hkDEMWoleTg1meLDYz+C0iDc wxnCQ7b0mLM+NZwHfQhSyvK7mkfhzaW/k7tG9/OhQz5jw7poJ++DFn1dCBRKBgma1CoT cf0x9mkwA4BGcAgJngKRf0n8+5LaoV5DnSjWUsChPk/gcCyGQES8HbcJrACSqLmokUhz pkLJHtBTGsVg8SFHvkIQyPSq73DEYT86QmwXAfkLgkEiceN+XOYI3xb2SKbMxyAOyo0B mXDw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=OpXzWlpJhscet03TTtHAiTy/AAuzQKIKHX9oxfpPCRA=; b=wWLahA71FRiVwgfp5r3547hC1KkA4nt9ubdrjsbAn6qGw77nMp6x+YSD10XY/WtbUe O/77P9c14J99xhKJoqSzYK/RM+tak9gmjYeAMgQX4jEq2oZr94K9nphv1ilyf/wYnTEv UczovL4JhVMTt1jEppUNIneuNQzgi+u80DwhqbTgET/Xe9nTVdpEdWhV29FNZXVbgljq dB+vxJTB7uRmOsxpk2aQ+Ixb5giYaYNebaM1Y9VcYhazh1Uhj4pLBGgbDrFEZp642py6 nqpoEO+c6N1fQphdhEfVXZfpnDQuY140/Wbt1e8fWYptpBxFiJwKgpportCAnDR+/bxh 1efw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Z40pSTqO; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id n16si20516513qkg.368.2019.10.24.10.20.03 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 24 Oct 2019 10:20:03 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Z40pSTqO; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:48556 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNgmH-0006Ka-US for patch@linaro.org; Thu, 24 Oct 2019 13:20:01 -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-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+patch=linaro.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(-) -- 2.20.1 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: 177575 Delivered-To: patch@linaro.org Received: by 2002:a92:409a:0:0:0:0:0 with SMTP id d26csp2472102ill; Thu, 24 Oct 2019 10:07:26 -0700 (PDT) X-Google-Smtp-Source: APXvYqyhHMVZ+RzwGvQ1tzSdcDTZHZzfKeCENjBHhFscdr/mzP/enWdYzYgH5pwil7C+8HdWHizj X-Received: by 2002:a50:8859:: with SMTP id c25mr21894231edc.253.1571936846825; Thu, 24 Oct 2019 10:07:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571936846; cv=none; d=google.com; s=arc-20160816; b=b4dhB8aqhHewfGwG390E5QCW4WcRSp1Rq4LERMCbXq3OOn1cdfu6PSAtkx+O/he4OO pKFw2jqAaZJbQFka5ml5I+gcueUErWlXCGt1V48GeOUixVzRhgAoaxetlcGIz+bikQJt PniFRmKB3bEXSBl092pptfsk91NQWHjzBHI79Pmwr+5RTkyZmJXlTeAjsmN70iALKN5W csLmqovlsiFn8nmHhIKzXxn+gFBfumu+yUTe6jRmwEAyn08x7CkvjxwhWx89fMPuu/cU AKhlHKet2hxP60B1ZQAdpLbDi7BUidzIsd1K8N752E3wyTrsdrqjnssYyUgPvhRS5aw8 ypfQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=SSIRbdIen/7fg/3VtseNziJYU9KzRrDZCTawNXozh3I=; b=vS8cFq1WdTVHzpeTYoYpCMzqxv36aXjIbEHTQ/MKlOlcuUVXm1kc8QG5K/0HcOCc9n omROGAKSDYts0dAYbiuZJtLG+XYXHriIdFe5O9Kx75Ejqp1ShuUySxXFxATxXb6ctYJL nDdE49lHyjLSDlt1E0dBetd3arxve/ghvqJ/atyQviTA1Nm5M/2PD9qxsrdZTMaRUAT3 3zPnzroxFCDG8Bmt3V2d74FQeOC3vpbUAdrHQew+yrJKzJ1pmcjcuB+K1TnDT+GUV6VW 76AW9EjFVZgia0eiuBLw+bBr+HDkGs6h+qyDAuxMtA3Z+lsJwsCikBOR+E0zhahVWaqt g7xg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=y22cxE4w; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id q7si13274813edi.103.2019.10.24.10.07.26 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 24 Oct 2019 10:07:26 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=y22cxE4w; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:48316 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNga5-0002gQ-3Y for patch@linaro.org; Thu, 24 Oct 2019 13:07:25 -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-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+patch=linaro.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(-) -- 2.20.1 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: 177577 Delivered-To: patch@linaro.org Received: by 2002:a92:409a:0:0:0:0:0 with SMTP id d26csp2476181ill; Thu, 24 Oct 2019 10:10:50 -0700 (PDT) X-Google-Smtp-Source: APXvYqxNfMP6NbD8yzGehsjQ0t+PGW3J9+GjP8qUp6PzuldE8/GiTlMQ4J+6kxMGp94qnZanJ0kz X-Received: by 2002:a05:6402:13c5:: with SMTP id a5mr25679639edx.106.1571937049964; Thu, 24 Oct 2019 10:10:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571937049; cv=none; d=google.com; s=arc-20160816; b=j/k7J1GDBDvL5yZbYkfIt20Gvs36c+QxCrocJMcSb2YgLHbI4/QJUiP00AYFAEtMFj fSDpv2rPvRBXyRkahoP8xkw61xQtvbS4JWJ80q/RE8or3w9SquG3ELODQOB3hg8NLiPz tiaIHniUaXi8JSNRuehfLk4NrasIyRz7VYFueFbon98nmAOK6bBdTl9UMbJRnEe5J/u4 V2Bixq3nanLZO028mKwrKn5v4LtBvQNGxmo/KsNLslCLnsitAv2nBBB0T3u6WgAk0JOY kaM5IPBZHKJHOzgJfrn0v1qSoKwP/lJnByOcf1cQvNZRN2YWMybtACiO8pkyq4/Gkilo 41DQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=mBAa8aOzaEjXceVb3slP1wzsJg0PhsoOqpMdKz0RtWI=; b=RUxrkM5ss3AeBgbUglPw//gEoy+5yVqE6G5fbpZHuNnU1aOyAggBJv5cnLtfbdfeg0 VC9nCtdds6dvT3js5I1nSXGGfGRVGlYCf1RMyotnN4J48cWfBEhNbfbjWYqPoJ3usiAE xHcoOAN4itvMyw2PqvIZDM7w8pSBfBnXYb31V7PegOX6eXoQYVOlZeNVF4R3fXcng4I3 qTHHdJ0tde9hWJCIeVwfATXpZJZ2liJElPKpp76jzd8bo+CubJVRxbDm0tOLQksBU4xJ IAVVSwzFvqdSZ1yqOrYKyNCvJobWiQat6Zzklef08yuiqyoHSzQo2XqDQrrIJuJ5MSLU Pjbg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=q5wOMzfB; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id h11si12333800eda.412.2019.10.24.10.10.49 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 24 Oct 2019 10:10:49 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=q5wOMzfB; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:48378 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNgdM-0002Mz-6T for patch@linaro.org; Thu, 24 Oct 2019 13:10:48 -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-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+patch=linaro.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(-) -- 2.20.1 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: 177581 Delivered-To: patch@linaro.org Received: by 2002:a92:409a:0:0:0:0:0 with SMTP id d26csp2478971ill; Thu, 24 Oct 2019 10:13:14 -0700 (PDT) X-Google-Smtp-Source: APXvYqyL43vB1IworVx2pxnUG3Pu9Lb2hKA9HAsT1He7254JFyODYa09VfltXZF1AC+G3yXhmv7F X-Received: by 2002:a05:6402:b17:: with SMTP id bm23mr44058513edb.6.1571937194607; Thu, 24 Oct 2019 10:13:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571937194; cv=none; d=google.com; s=arc-20160816; b=j6JRMdBMKPaYc+fv31xlO241fHQPxRLa+/WFAxV6DrqNrCACUriAi7wp6wRnzV4pNR gla9mbFWaFwi2BFOEseojEPSgYlqOy0Bs/hFtaJ3KC8E5VxTQff968Z5p2tXElUq+HHB b7zn6n3hnOfJN8bMkVDpCnT+n5qBqJGa6Ho66YhZuE98v6UHAioFrFIGdjc629YPQi// 3C1tUZaUXyuH5feKmKqafA2SWKNRlGfyfuF5DfA/Lm7sdQTntlUPDjPRJLCl8cp2b9oJ l4+qw3N9f8ZEc35fUKZYCwLxrA9RVGTBwrSToXzBrqmF3Orhydj6qCjgVCuXK4C+UySs R7zA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=J21kyHeYFa+RY7GcWXJAZvmmTTUgznnvXHxn75vs05A=; b=UuWp+w24GkghhYv5ZNxcbS0V0mQsfwZ7YH1snns5yfu36ptitiOyy8ZqeWtTYjjlqR egDJ/MSsbhUO6U3r5a8d3V5GfyGfFZVBYwECSK5+s904Bnm8Yq27JcQrab0P91kwCGFG 0eGUz6t736IZmtzYr2eVBBrTZchLfBymd3tNTVPH++kqMOXJtJERS+Ffnl/1TXG6Yrq/ Cy10uvYLIWH61GZ7xtuheQSgK+Be7GaQta3bRqOOAhdD3H+yGgOQZJczp2ICNyN/5k0D kYLFyTpEYgWSao0pux1xzPHoGnT44zpORNlVktUae6Aq5iJdWQOylk8/QHDr/xfz9Ubk gzdQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=c1UvOL+Z; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id w11si15066041eji.160.2019.10.24.10.13.14 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 24 Oct 2019 10:13:14 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=c1UvOL+Z; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:48416 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNgfg-0007Rc-Ht for patch@linaro.org; Thu, 24 Oct 2019 13:13:12 -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-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+patch=linaro.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(-) -- 2.20.1 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: 177576 Delivered-To: patch@linaro.org Received: by 2002:a92:409a:0:0:0:0:0 with SMTP id d26csp2474349ill; Thu, 24 Oct 2019 10:09:18 -0700 (PDT) X-Google-Smtp-Source: APXvYqzuoSDv4nZBhc1CUUShQMhkF9zueJ/4iRXEsOfE6UhJspnS6W45zczVB3wGtaSBc7OZU5kO X-Received: by 2002:a0c:f984:: with SMTP id t4mr2447732qvn.23.1571936958519; Thu, 24 Oct 2019 10:09:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571936958; cv=none; d=google.com; s=arc-20160816; b=N05bAS7mS3YmljglL4EVJcScddrrKSuKOA0BO7XuALmHuv+ugKnsoz274/6dNpQ/mt 99win1/swVSyD+c1Uw2x88yKh+3p3oWHv61XfWNNhahmBlQhh4gA3VypY7VRrUY9y+LR Fp/6xw6n3yeMKTdSIVijy5DhU+i1iMvMyh/F9/usfh/KSCbwQpLEyUiQkIHJFR4GqN2k gRlN7ibjech1Ssd285WVvsC2r82zpmcxNgVc825cf43VZYA3atAhsEcDvRAaQ+WWf6eL uG1ChGCK3znmTqg/lpw10QIV1pXr+IDRhp2Z825gJhKEQMpE4IXn1pEwQ1CeaxlaaI9a oO4w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=8gomn01XLvBOBw7vPQuO9R/LxnmjSiX180WMSIb6GFs=; b=xL9UP4A+7EN0lEnd1KHNoAwPVoL+kHNfZz9Caip+sjWuaCOtxHS/u92YxYDGesxKCP syi5+Jd/Li/K8LmkqSNPgEhDGrdwoh/DZGjxN0WP8wAGJKVxRSqqFex3Mw4QEMaxyu/b kuhpmM9fkmBtxs+P5OZPpuccjwCWYOhycO6O3b2btU4ZRJ9XZ8sVfC3LBdw/fgWt5jvf BizFl7HlbGsejGbPaMhocBEZ9wmT+bUIB1G/p4QQyBVnh5/H6wvsLaogvpsmBc11PmmS MDC9dsZZb6lfs8CXoDYJGV3qPcvX+XDLzJVftIHWnckU7g8tFMGepw5gmZT/mhwM0lrk QZMQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=bh0tUVgC; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id b67si23136618qkd.109.2019.10.24.10.09.18 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 24 Oct 2019 10:09:18 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=bh0tUVgC; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:48352 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNgbt-0006vO-Ei for patch@linaro.org; Thu, 24 Oct 2019 13:09:17 -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-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+patch=linaro.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(-) -- 2.20.1 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: 177582 Delivered-To: patch@linaro.org Received: by 2002:a92:409a:0:0:0:0:0 with SMTP id d26csp2479600ill; Thu, 24 Oct 2019 10:13:47 -0700 (PDT) X-Google-Smtp-Source: APXvYqyfyuhTB/CLVDLh+LQyya3QoM7MWdRniBj3bG3Uo3d19lj4F63u8rBmFqOxsdAGJEtN5mZ1 X-Received: by 2002:a50:cbc2:: with SMTP id l2mr45233855edi.304.1571937226970; Thu, 24 Oct 2019 10:13:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571937226; cv=none; d=google.com; s=arc-20160816; b=J47EpFIZ4hmzjWeCsOUr00f9fOb8S8IibAUGGj2yWDiDpC9cihAnJtHYtMe7jKOS2s vtcRLrRbcqPoRhbyE6e9ZlHpc8FXvTk9dK7XHkhVEdW0hn9d9wUUCO+GmjNQOFij5vig Ng3gw7f+rIjXVhiCK6RHpAGCe6/ICNnXRxx0/s+w+DRpnKgeHXauhsKyVPazCzb4HRWI BgZ7LgeH2Hyxs62p7U97nQd92Fwi8pP15eJeEFR4ZwpF+ntQl8OGMakxAtXHYtPIWjt2 +fCDRmfO/sZHkV7v9MCH4Llc1WLFb/uo1EuyykoO8j6Rzd9xVbVTXI9vlcEIDhCw7Pl5 UC3A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=BcKgN/Z0ywVj7mxh6SURNZkc+EcubD4TLlWRL+FxQrM=; b=gRuD6akv27atM/sk3a/6YPeYLwJ5V235ShqLW2kse3Yycie8ahIaHvioFeRtFWHZjr Gax5B4tNhFV3TiCt9F1PB+mtUj6NiBTjfG0l7wD/vYPbVbfSsAS2EUoJQdcV+WGRYnj2 WUaguGDEFwWZpZHjVo6yLtx57bRFl//Jnq0iVRla1HLg92WDkdfENj6dqAaKPGbXR8CJ HzR6Pr7u7gaLcfnXWbEHmTJF7kqxhRvjlFzz8G5wzOdUjdRrCdDDvd1pL1w6qnj87769 fg+H6LtWvPEZpjRkVQnNXi/e006gN3wfcK5Qv0B0RmSVpGjpD3ty2QpCDxIkQdY5uZZu CjWw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=AtlSwa1q; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id v16si15174015ejx.96.2019.10.24.10.13.46 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 24 Oct 2019 10:13:46 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=AtlSwa1q; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:48420 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNggD-0007fL-64 for patch@linaro.org; Thu, 24 Oct 2019 13:13:45 -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-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+patch=linaro.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 -- 2.20.1 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: 177593 Delivered-To: patch@linaro.org Received: by 2002:a92:409a:0:0:0:0:0 with SMTP id d26csp2493766ill; Thu, 24 Oct 2019 10:25:49 -0700 (PDT) X-Google-Smtp-Source: APXvYqxqn0LPaCIH/cbCzgyNYwJHGtEzQFuS5SkgGzoS4LRZQn8d7iVvOsbM1tLH+lk36lxVpY10 X-Received: by 2002:ac8:2dda:: with SMTP id q26mr4442329qta.100.1571937949278; Thu, 24 Oct 2019 10:25:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571937949; cv=none; d=google.com; s=arc-20160816; b=BzFtO8F4umSjXBLLKl4PWQcGb0ol6QmmZAGdjG9SwOmgdRUdyHl91KTciJau4BzVi8 dX2B4v6uKDctiRz7tyhJR112wdhsz4iboM33lyPxXgxiexDCOPZ45TcPX/971b788jC+ BEC7Y7BTKPVnR6LOu0/CQiKyrKSmeMlGKrvoGGk5ObsjUZ+ehosIiQbJSGKfwNZlh4WY NNdByHp80lapJfVIRZABWzGWqE7/ergSx1jwbu+u8SpBXSoTHNnebyuJNmUs45SIynt4 n8Y7H/fILfsxKTGRC0U7+JIcizZdOdufni2u8JgcxSOJ/s8lQsBv5jpcP89WpBYnCJm6 0Rng== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=1ppvb5bxHlUarLcdtxXV3E1gkwxQBUxp+2P7V8J9BmA=; b=kjnntqFuWyjVSPjBo3jiBfLDCNPmiKyluBqTtBINJACr/nq92PXV43uTinMogbtMud tZdXtvNJT6nrHeAHqk10pf19PDswJZlWcSGLYQy0DreoW6daNaS2EKyRsqxUJ/3pDaHo VZd7uAo6WEhxRxs4Ceb1OKWVgwNAg8Af/BGrLDDrYgLvWnI6R97t7sQearcXCBySicfu f/BggWMeLDBsMYOHtLvLjEfvLFC6MNFOlHkWy/aasPkkBOK3jQDJNksCZrtDRONQIfL1 A8DwEp+uQAo+DL8XGdlC0ZTRElvLW5MQC1DZSXU3+5gnruVLdJrvY6AX3o7HuoV/Tf/i kvag== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=FrbNTW8k; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id y6si8978800qtn.173.2019.10.24.10.25.49 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 24 Oct 2019 10:25:49 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=FrbNTW8k; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:48668 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNgrs-00041P-JW for patch@linaro.org; Thu, 24 Oct 2019 13:25:48 -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-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+patch=linaro.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 -- 2.20.1 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: 177580 Delivered-To: patch@linaro.org Received: by 2002:a92:409a:0:0:0:0:0 with SMTP id d26csp2478443ill; Thu, 24 Oct 2019 10:12:44 -0700 (PDT) X-Google-Smtp-Source: APXvYqxRpQGGrcXL4tg0H98zZ4JQnBwwFw71Hve7V3zJyRQaIekZd3lj5fwbdodyOUUAcZLIyKqh X-Received: by 2002:aa7:cb5a:: with SMTP id w26mr44841941edt.188.1571937164134; Thu, 24 Oct 2019 10:12:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571937164; cv=none; d=google.com; s=arc-20160816; b=lo8h8Ih5y/Cb/KHaaeWGb8/kvjPO5ghwJsnRmRgrCx/GvxmK952vJ4G7UtPra/TdTP QdmKiY2Gc6NVk2OCIU+nMEz4KrRA7GSa4PLKQ1373PmCyhPn972CxjBTNROUZasGWJHe 0gWv1oHVhNi9O6t/5+lTi/7+nbU5JfPTShMUu3WoiXX0F0Xbp8wuJPZG2glhZZSqgpgh kGsuUmRZDs4YzE/ZKwPCsjhQdlrYAhVlJOBA3jKWiwt+Wii4zA4z1dgsz4tBulWHGxZ2 3YiOH6TZ6AaToiFDNeBOIklFNpGDHISsvQdv8V2+Vn3fogRXlxw2Z0601LMCRp+Ra8cV iqCg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=YX5kAV2V+51rIRAoIJH8dk7lXcJe17TkZW9vBLdbmdY=; b=KwvBM4Q/wo73MC5xsdN8uXikQJX9R6kl+Ote1wjXFDAkCpd9U9fY1l9UlzVuhhT29P Bogdfy/U3NwgrflyxILUZszm4sitrcmkIOMBzeof6YrOSHDA872WAxoVGh7jqtMY5U7y K7BL4NfL4E+cf0vZvcPeiAXyIxofkbRU+BHP/5kSWGcnL3S5wDkNIXqeai5pKldyu5Qr 50C52ZGLSR8gT0XcI4HHPKy6gkWZ1g7BN3ULp0KzZlORPRiajPoHXRZske7s/5S2MydJ LCI10PuStfnymF+hJwQ28QlvncPu18VlUOhJ8XY4093uSsqQDZuEEapx4YXJFeIgTg+D fjGw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=zgdQDlmI; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id ox7si5711402ejb.190.2019.10.24.10.12.43 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 24 Oct 2019 10:12:44 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=zgdQDlmI; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:48408 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNgfC-0005Vn-Hj for patch@linaro.org; Thu, 24 Oct 2019 13:12:42 -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-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+patch=linaro.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(-) -- 2.20.1 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: 177594 Delivered-To: patch@linaro.org Received: by 2002:a92:409a:0:0:0:0:0 with SMTP id d26csp2494535ill; Thu, 24 Oct 2019 10:26:30 -0700 (PDT) X-Google-Smtp-Source: APXvYqw4vHAxJ2UJxadH27T5PaoIUo5uoc7u0GUILylGRuv7EjOoJ0fOUwnrev46kbtlLre73tFN X-Received: by 2002:a17:906:6d82:: with SMTP id h2mr38682655ejt.127.1571937990791; Thu, 24 Oct 2019 10:26:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571937990; cv=none; d=google.com; s=arc-20160816; b=rDwF3eo8pPHYkxmf8ZYND8df/f8Zw31OLvL3NtbiGFDqcjrGQTVy//DN9G9ZfhxNS/ rZzNaj3jOZeHsab9aeIOAi6GM+axfMswaGjHv2qBSEaH/ca09RFpA8NPfjtEiMWp8VKp VsHA5zD2/a9y+yE5CB3Lec3O2UDqYpsoVEenOXoahPapCWFnZgRPeY8uGVB6CN7XhkhF OgCwaYVCo1YvpoCSyfhH20HqSDxG/VWZJy7o0Lejc3Y2fOoPId7SexU6HOZ481RR6j8l rRtqTn+8XpgqYphYd/awlDbw7ejBKv3KFmz4fS6sjbrJOZom9AohSPzRKHLJNlCbO6Zd o1Yg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=a3E4jS/ojygIRXGs7ta8idsyXZSz+sc9Y9b47EiXEPY=; b=zf+XofH81D6CRxouR6E0N9JkSyEh1PeObSDrUOqrXJdb7iL5U3KUaIJ7x19kFMXenI aB8Klkd9/5MJp6ZqwZ+0xDJT+qiC0IACUWCEAYPpTSCubOYNzp6gQTZouw+Ff7s2raTD mUkLbnISLWe0d2ylSqrF1ZfnUeW5FRDpPZi0GT6XciUXTWNlMKAuOu4FTF8NcQ5hHcAO ovwiO7d3IIiCSjfUBGDx7PNZmbpgjTKq9Iuz2w+YByDf3e8t/ySaU/A5ebgT146v1+qc YjqCqPGwzmKlYHAGvKlTwYObJ/zBIy6fnY2GcagcRJ6zxHuxNeF8cUhdvVVjwy0JKoOP 9QVQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=WhJbq2xi; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id k23si9702440ejr.298.2019.10.24.10.26.30 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 24 Oct 2019 10:26:30 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=WhJbq2xi; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:48676 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNgsX-0004KF-Eb for patch@linaro.org; Thu, 24 Oct 2019 13:26:29 -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-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+patch=linaro.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(-) -- 2.20.1 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: 177583 Delivered-To: patch@linaro.org Received: by 2002:a92:409a:0:0:0:0:0 with SMTP id d26csp2479967ill; Thu, 24 Oct 2019 10:14:06 -0700 (PDT) X-Google-Smtp-Source: APXvYqxXe9u3ME2SiST1hYBhyI7k14E3U5QnH2WpPpCBLF0zsllRiFd0oju3KS7lkFibu7qGrfrV X-Received: by 2002:a50:e445:: with SMTP id e5mr44132453edm.257.1571937246085; Thu, 24 Oct 2019 10:14:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571937246; cv=none; d=google.com; s=arc-20160816; b=EMQ9peBofZ4CKijPkRrqAB/7qexb1Mex7AGIpT9lQWoyH7wy7ct1yWh6DiV82saKdF 4SVXs29Yk+p8tPK1SZOnWN6mMe8UzE5+BFcHngncMKhHk5LgyeO/DgPouCcbANnLgpuQ 9vS4SxvOFAcrnhIwAG4IjU9d3iZ4fDezn/dGW2lwMGNHe7UM/g9G1UxjbCqCnlrdBf/Z qtYQ1VNKzELXyg4SjnQ7h8Fcum9avCThs/trtCvE/6t82XHWflTINLRUb4TFUYlRTqDW NgZssOitKBjIS0Sf4ipoMYJl/MHhfuOhgqbnuqS8lrtxPH+8KWxTDvZqlgb1PjyOJOlU 7Kpg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=hCsDjq3BTh1CFQ3xfAyc1h9/b/i1zEMVd9NMkBRbhe0=; b=xNgxkyoSi3Dr09GAWKzhwZ+wH+amtieajSIAA8etJhvEYDE/FNfLJrparWVATdnGHY 4CssgnuHEbMUyprxI7uLO9SYqwONR3aM8VM9vW/SVlLtk1XLVw2NXUKmmAnk9oxhaVRP EAIWM1zT2ylWuQK0uGxbPJUYdbvNHHbC60rNMQuRj71up1G98Sn8ANpQTgKLgER1h699 pQWZzDouzSHWcC0O/bZM/ek7fdfzK4y1p0W+yAcxsDCBd1YCCq2RZ6oJECAi0Vqb0LiC sYB8U/GrSBk/RicLkX7WB/q6fq1Pf3kSF/mN50Mv2qbfJmddb9RUHuTjAbLavA7N8xU9 qvUg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=urvci2Ek; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id h22si6726290edb.346.2019.10.24.10.14.05 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 24 Oct 2019 10:14:06 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=urvci2Ek; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:48432 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNggW-0000tY-G5 for patch@linaro.org; Thu, 24 Oct 2019 13:14:04 -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-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+patch=linaro.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(-) -- 2.20.1 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: 177585 Delivered-To: patch@linaro.org Received: by 2002:a92:409a:0:0:0:0:0 with SMTP id d26csp2483093ill; Thu, 24 Oct 2019 10:16:40 -0700 (PDT) X-Google-Smtp-Source: APXvYqxsMvvJuHkg947GKjuaJuXA7AZzWh38Zg+WChv6zK1OZ29wleWzE/pyjIeb+jUYwW0mJtdE X-Received: by 2002:a05:620a:148f:: with SMTP id w15mr3912267qkj.341.1571937400661; Thu, 24 Oct 2019 10:16:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571937400; cv=none; d=google.com; s=arc-20160816; b=Y6il0uNZ/aVnd0AuUknThvNo+glh+oEQGlHZ1RuYWkukLDuwoFJ19cVs2kYnXEmhbY w/CMYVXdi3jOsOdaa0WsDbw/lGCunxyiH3LhFcP2E+OclkJs/S31/jKnEQ157O3IbS48 0R9gFP8tgoQfVlD94U3Y/rL8gaI6u0cxHJPAJuYSXY58wnHRbEG4/tFBuvORTJHr8xjk plh2DCpVMTExoP06wlXvP0r8az4Wy0wapjqwR/HavepKGPt2lJjijoV7GMzCkz/hCyaC iL6QpRo0uver7J4RGHGjFwkfSpS+0FFfRcwTgaNH1PlhsO5aSzjZ9bg4lQ3lKfdngZrd Ytyg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=I1XdSXHXRiwCyyQ8+g7Xy9Yc2JAcqF8GhBJsyFcDdek=; b=p/A/qCoM2fIAOUgdqZyzNJlpcheekY74a63GIIAfb1HDylb+V4//CDK5KOnWd9lmir jOJO33nGbRf2aGSn93SkmNuDoUEjEAMiZVc4ICIlZN5NZlUPusv+mEzIrE11NfScjmGp BENrZjhywiB9o/21R2hQD7jFvO9W6dMkYDh7oFj1h9d99Xd1OvG/CSqRIIwirPlkANII KE0QIRqoQZu7qRGigQkmILeJa3JncmBGQxI/B9PIhiWkiA+f9AQP/dZs9V436iNXGX9Z TSuZfbyykgWIX4I8kc+LG5EPzLR+XjbDIIdSkeU+/U0fACy6JTSezXW1+PyV9VqNQvb3 WQvQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=waRai1xv; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id i21si1502055qkh.308.2019.10.24.10.16.40 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 24 Oct 2019 10:16:40 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=waRai1xv; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:48504 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNgj1-00052m-Ks for patch@linaro.org; Thu, 24 Oct 2019 13:16:39 -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-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+patch=linaro.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(-) -- 2.20.1 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: 177589 Delivered-To: patch@linaro.org Received: by 2002:a92:409a:0:0:0:0:0 with SMTP id d26csp2487000ill; Thu, 24 Oct 2019 10:20:04 -0700 (PDT) X-Google-Smtp-Source: APXvYqycpcUixKRA6tx3mdORSriiKQdM3mlPSDC8ps332YzaqtNZVaJQxj36zuzcQxFGikN3yjYV X-Received: by 2002:ac8:3142:: with SMTP id h2mr5607892qtb.182.1571937604293; Thu, 24 Oct 2019 10:20:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571937604; cv=none; d=google.com; s=arc-20160816; b=gJNJaIQDg7torOh0OUFMcYtWRwOXWSRiMNIa/1mvthh4cJMkWcaP0Ibhp9YaN2nB/B bC6JUJfrdBsHPMnyjRC9gSkgALztbhLEC+0g59ZlW/SgiklN8DU40GT5Xqe4pIxjW5RV 7RvxHCxiEQosK6Y5hPGtpYybJxq0DqzrJsP+3oB61jN1C3PE0Fr7Z7AJ/IJyaWUJNLyE A99+zteSg5y6rRhZ4QpET9sNg+IPPJ+nhU3krZskL9ZOn5Tbt2X5V0lsbQ2cI/+f9jBl 34aBcGt0iH8ln4NiKj7Fnc6V1/BRYadcpSNSMGbJGUxnDCIpZxigvpbZaawhuKqQOZ0P LFHQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=0ZlsAUBDsUyvYREq9UC6PUhIuy2cFHkEmU/zq4fnk1M=; b=vB/tKazEWR0qvi3K7R3o/fhKfGXWJQutnOrs0eA0Z5L5Ju0zSXQvMQd0xgxhWQtCAa thuWH75+/SuxOcnKkbc3iEo14Q8icMdsWdFN16cVG0WnRdskSZE7JEo1TqTnAmcY2T8o uQJI4bASka3FKF8bOlFUTo/uqmh7qyGZF3Ri8vg0XUDrTBQQl3EVsrVOBqMpW1n6kwxf I/0AO/3B/ad5OjnBDDG+0rG/FyWOW1Ka8QfrwDGIScjbKHU52sK5MN4xMstKgveGIN7z qmIBlNG0+5FFGK38vhOBkflQfg9y94upZ0HQpGwpJZ+jXyrDA74emKnh27XllT+wynGy cNlQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Ron7P1Kt; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id a18si15135829qka.78.2019.10.24.10.20.04 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 24 Oct 2019 10:20:04 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Ron7P1Kt; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:48560 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNgmJ-0006Od-2c for patch@linaro.org; Thu, 24 Oct 2019 13:20:03 -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-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+patch=linaro.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(-) -- 2.20.1 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: 177591 Delivered-To: patch@linaro.org Received: by 2002:a92:409a:0:0:0:0:0 with SMTP id d26csp2490766ill; Thu, 24 Oct 2019 10:23:06 -0700 (PDT) X-Google-Smtp-Source: APXvYqx5Wrb/ECLPUQvv2HH3ekJXFFvOr5ahDr06bU1beiV16LD2lIN7e2y4fUCn9UlHhwsp/mq5 X-Received: by 2002:ac8:247a:: with SMTP id d55mr5434085qtd.122.1571937786431; Thu, 24 Oct 2019 10:23:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571937786; cv=none; d=google.com; s=arc-20160816; b=Dqxv24eBQwu+EMcNkyv+YnzCXNz2nNyZX6UCgq7J7FQ8Mzlcn/5hkfr9oz6mITISfo Aepuf+O1VnuDvm1NCnb9LT45yw3h4cUwohGUr+hRQCIQ0mzun+r9i4jaEwgjVGjaX87P cCPKQ0sNVWXITTnoFae4EsSThhcO4cnxjzJOetZ9Zl7D04N6mMolZTI8AVGiy2Xv10/P P6axanNX5/xlNofjJTMmh0tixbPxZhqYn+3fCg2NbOOpJtv/82u1yvgSUtByO9+p0zfx DXwk1oANsxnEZ8JrDMiY9N0ERxc6sYlc+ibSq/ESSkoFoXK3vhuJVs28ujPrsgMLs2a5 j3gw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=ZeHKzgmsDen/QyhbQuCt1PN7vpHYJaMJAeCb5HkfWO4=; b=K2iirFPArauVjc8zlOF4xEN+sXNyYuz4og1LKvsxeJpXY0hBjT6gjzqbaC5GjySoka CjB4suTRg988gSjIplVQm6QoWlXD+pSGriPt/5vINp2twqODbpqNI/SVBP/Go9s2+BUx Z2A8qM/aeqyCTDpYPvDilVlGuk9YqQBM+HEm/Ylg1SsO3KqhDQEG1nUCAtSXHG6sxKxQ 4m7N86DVmm256GEfZ++0KrtgJhsXmu/BODHhOCQuJjZXXjOEZaV/nVmhxIkSBY4CVDhM w7wauBelUZotQAMA2mu8L7pduNR1rT6cKMdFyzxZsO5QX0lcStI6ZX8ecanTAxnXX7X1 nSDA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=jN1voNpb; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id w42si23460699qvc.132.2019.10.24.10.23.06 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 24 Oct 2019 10:23:06 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=jN1voNpb; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:48614 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNgpF-0005xX-DL for patch@linaro.org; Thu, 24 Oct 2019 13:23:05 -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-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+patch=linaro.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(-) -- 2.20.1 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: 177586 Delivered-To: patch@linaro.org Received: by 2002:a92:409a:0:0:0:0:0 with SMTP id d26csp2484623ill; Thu, 24 Oct 2019 10:17:59 -0700 (PDT) X-Google-Smtp-Source: APXvYqyKLxslth9QwF1Pg4jjhuc1KfZmKYUMwERdLaXegcPuWWLxE/ayEtYkQauLv1nyEHjGnfTK X-Received: by 2002:ae9:f204:: with SMTP id m4mr15191031qkg.105.1571937478841; Thu, 24 Oct 2019 10:17:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571937478; cv=none; d=google.com; s=arc-20160816; b=hu6Asu7/bndDgDSAA7vKXzHwv2fKcoCNS0CvyiBimBMaKXOFNVVvFemTs1OeCH2fKP jkT1Qzm5SHkZkPatwYZOop1AQiMvPsGmSRQSc1rY6gFW/jjg7zOA09S5OwTonhTwzemW KU8HK2BBpZe7MMBQ9Y8o8MmZkeVPlV16b1iMQdmFHuMfsew5vc/Va9Sw3DFQHLHF5qN+ eY/CZx10xux9++ZnnojDTCrQ7jLP3dpSfQ0An+slp/WAJSDXn4pvvms+aTghZAZAnixm 2aOuKI/mcqLLMRuPDemCEoYgux37doTcb8owNxE+nRks+qja1KrD9Anil6UzZJEVpedT uapQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=wSFmtC946G7bKfZfsaz2Gf6yL4qS0CVGiz6hotSxhvk=; b=r6bEAdUCJVcmkBA8GweX3x5N45huHWtcdkj/2CkmvpVaAjOMPbboI0CxmlCTS05v58 87HdPdg4PzhhTI4DGe3Utl+UseAE6mg1NwXlXCJWhNpNBGfyvh34q8dOzWmRHzspMcHY CbIDy2q4G3yZt3+5XHH4k0QnCcakmIbKZ29QBBYQ7sGmC7kZJBXv/y+jGrTN1fyWAMhK tNbz8UCG5SERmIjPW97M8aIDtv3UnuAJxW4PN9fuQlP48si1W/A/WAMDXumb/wq1Ncy2 I4c8Ol1CHZ11KzjMI0Tr49olK4p0GqbhyfG7oGp5s7ANnNbg23aeq+IsTDKybpO8ZhsV JBhQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=OgbaTaSB; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id a6si19625699qkk.260.2019.10.24.10.17.58 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 24 Oct 2019 10:17:58 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=OgbaTaSB; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:48514 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNgkH-0007pn-MP for patch@linaro.org; Thu, 24 Oct 2019 13:17:57 -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-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+patch=linaro.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(-) -- 2.20.1 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: 177598 Delivered-To: patch@linaro.org Received: by 2002:a92:409a:0:0:0:0:0 with SMTP id d26csp2498096ill; Thu, 24 Oct 2019 10:29:53 -0700 (PDT) X-Google-Smtp-Source: APXvYqy99RaUi+Z/C0coAmlzrt9rt+b54zuEYPS6VuTCtcnmD5VpoEhgjcMZLOa7BxHzieAyYGYG X-Received: by 2002:a37:5842:: with SMTP id m63mr15002584qkb.59.1571938193630; Thu, 24 Oct 2019 10:29:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571938193; cv=none; d=google.com; s=arc-20160816; b=V8KEZ5mJkMYqCLUiuCCuzbkLJsH9LY2VWsfvj3sqWUQ+VHr71hLRHmBaJ30KaUZQyr KyGm0HXeb1+payfS0uE64EEm0asHXnkUW2Fj8aI1gPsNoF+vtt125akIiGW8VQwyjta+ 96jR0jA22j2nRPYB4l4WuRS6i+bxbvLDAyRmPfoaRAs+OsatAEgsnlCMSjIkvX8js2UQ Rm4OxXnqPdrW0z7hmsjdMIBg/A94VF9na8kQlYoaFl564gy4/4lkf6qsB/bt//2X3j4e j9TCED9hveSQkIqlmORo9+9smjNfLKGA6yMuUreQnrHJa3n9/y1ounbMc9nYGmZidWaC 8d9g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=+7fLMOIAWdycUDbs1+X1UPaZ+K02U2cR6zHlqPFssiE=; b=ykA6tq5Ps5c3j0O9cn14brrRtSBaWWxseSm+sIWPnEeF6+kpHZqOT1arUiLAed0EM0 mDfemMkyR3ijjnmxbWUZB4C5fwkaSmO72U9CIWEFlIRiNSiWjpf+8nKA4WvQSWUOIfa8 GppCTMQFuXhg5kSbcpJ0oBY+QS69Z206A2tKkx6m9ui3hJIXc+y6e3TtjewF/M4hwXjs PJXzmNOgy4R/i/fI2e+1Z6T31+MGivElXu4ckJJ1VsKKxYNWZK06/NrFtzvGqa/+MWB0 wT0xEMrOvQ+VDYdlwAlPXstfe+bpazYJRgM9LxpW5BkTevX8/8fjYHLrWEwzPZDnytqC yMjA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=bJ4jbhhc; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id o19si17364499qkj.182.2019.10.24.10.29.53 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 24 Oct 2019 10:29:53 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=bJ4jbhhc; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:48751 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNgvo-00049a-JF for patch@linaro.org; Thu, 24 Oct 2019 13:29:52 -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-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+patch=linaro.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 -- 2.20.1 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: 177587 Delivered-To: patch@linaro.org Received: by 2002:a92:409a:0:0:0:0:0 with SMTP id d26csp2486336ill; Thu, 24 Oct 2019 10:19:29 -0700 (PDT) X-Google-Smtp-Source: APXvYqyed30NOZatUtuYMwjqWMy5yt5f3L6vTSIFBzpDewZLMJ1SRcP3vxRVFsJTD6svBaoYcnpn X-Received: by 2002:ae9:ec11:: with SMTP id h17mr4175879qkg.485.1571937569114; Thu, 24 Oct 2019 10:19:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571937569; cv=none; d=google.com; s=arc-20160816; b=DOB9aXmrHwV8ImwXjvzg3+w8MfPbU2WGAd5EG+hE6u6GUrhlTPIm/qoOPQavbSSIZL +VXuaeKU5e3mVWJlGoDzzo0RTJsttYbUovMMsKZ6n1oJL1Iv7HOz6uP6EZBdv0TU4QJL Rk4M4zJATMXsZOMm+Vnzd91i07eD1okkb23J5afCw84GNvoOGvcl35qJ2UN9Y7/PDijN DNNrBu0vzRsPBv9OaPwixKkrDdAa1OPCsUSuDkp1mFsJ/sIiByyHzSo0OQVhUg4NTO3o iXZLFudx7CnJmi9un4Wcf+BN4zBEQgcPFoCwMojEqZndFbisYvCU6/fpnG/DGe8oHuWS Lj7Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=rFFq99KjNRPKwCumrUa38nTH8zpDsdg+udhpyP1ndZA=; b=NDZRPuiM1pNS+LaV+xzp6Dy3m62G9FYNPB3IigJTuapTi+8uE9VT758B/Ua7xT5mFB IGYDOHPEC+dHmGU7AearjVTcRagap2tG+TDFMU7V0LD3aqHDt9shte7Fa+gvxHubNJxT Gv2PVvk8MYXqCQ2kNMh89HS1+ikniUOPZXfwkyAyhzgq+qKZzANjsy0LwpBwG6wfAOcN oT7ghxwxuU85wh4kpUKhta+4vUOue7hjlZzTqKdKmK0SSlDNdZpZkz5WjXr2KJfcYF1Q U4jQpvMi/hkIxtMaIA857PicafNhAZez6ErIDNw1q/rXA0bQmaVOZvmgOI9wISoWIuPQ y1jA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=gh2UpAr1; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id k2si5821342qke.46.2019.10.24.10.19.29 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 24 Oct 2019 10:19:29 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=gh2UpAr1; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:48534 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNglk-0005ko-2G for patch@linaro.org; Thu, 24 Oct 2019 13:19:28 -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-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+patch=linaro.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(+) -- 2.20.1 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: 177592 Delivered-To: patch@linaro.org Received: by 2002:a92:409a:0:0:0:0:0 with SMTP id d26csp2491760ill; Thu, 24 Oct 2019 10:24:02 -0700 (PDT) X-Google-Smtp-Source: APXvYqzuM+5ECkYW2bmmif82FeqCo3QhU2kt118K0PfZlV4TjkK5AxbSVykmQFPUm06EP2tBCfMK X-Received: by 2002:aa7:cdc6:: with SMTP id h6mr2424146edw.243.1571937841943; Thu, 24 Oct 2019 10:24:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571937841; cv=none; d=google.com; s=arc-20160816; b=f7/ZQvNNT2YJ2xXr1+20o6Q4mP04PTnPzkgdpqx7e2EL2QIqiksfuYs4oRKKjpjgMy lArT/vfazsBltERTu3ZH3cl1PRKCCKvSOAGMy5AP+kj37MYHfGwa/QuO4nJ7hrFV8Onr oFZILPW+Nko8DEWFhrNsFSl1cm71rk3P3THaBGb3zW0+4imaCIJ1A9TXfEn9Cm6DOB2i /DfZnRehhvEPjh69eJ+KXOphRqNAb7zNKSP3cnKN6Xjozo8y/Nu1CFEfza6v0lAXCyuw sHS9suMfLnYMSekWOWQWnMqi9faPcCqSJCRqWxHA9trEiKK+7TKT60YzWkoMzjidsW4N clqw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=vzBTgyNx8Q8kNnyl3gqBcooBFcldGb6ykyZpy3nNnJw=; b=waiY+LzmKWUgFy9Js8LJvwJEOuqmYNeZDK7naT2ia05CrpntawiXYL+PU0MOA/XXpS TFTJl8c9JUGTzCX7YaHMJalD204Yk+P6EmJJo8dez5luGtKkC2ucIRVAYrT61femE2zO Nn3YNpUnCZJsDxKb6RKh1PwqoDzhqrUgmrkI2VbyHuECGlyNr1fOFAuOJyuK6Nmar8ah xnQuGUsjnXtXoA7P+x6MdRcbkwfdLQ8tdKeuIHlveey2AWlgWVjTy/iYfz8M0ZnSIude kWQmosTKvSf2LWvu4jsjIUDaXqq20bnVTZJOQDRSKmMkoEG8kXIu1T++7QTrCb2Nr81G JIvw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ZdOgtxtv; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id cf22si6169480ejb.290.2019.10.24.10.24.01 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 24 Oct 2019 10:24:01 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ZdOgtxtv; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:48642 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNgq8-0008Lb-2n for patch@linaro.org; Thu, 24 Oct 2019 13:24:00 -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-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+patch=linaro.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 -- 2.20.1 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: 177590 Delivered-To: patch@linaro.org Received: by 2002:a92:409a:0:0:0:0:0 with SMTP id d26csp2488627ill; Thu, 24 Oct 2019 10:21:23 -0700 (PDT) X-Google-Smtp-Source: APXvYqxWmLgi7Z1GueD1Fu7uOEueXrgEUSiIlgYe3rjXOKJ7XpPJR1YUafjWmlMBzj0xAIBeICWT X-Received: by 2002:ac8:1859:: with SMTP id n25mr5194783qtk.333.1571937682965; Thu, 24 Oct 2019 10:21:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571937682; cv=none; d=google.com; s=arc-20160816; b=CUdjn11myL8cQX5TdLkDXIVPsWbsoRIAicPRl2ROlHqGIBchCVbSwSMOFtq9JkjI4u sITNOksRDZGqhQ72ld/i3GJ5yyQ1mqDczxw/8eZvrP4wT4ITG+veYna+HVP7Q9p1eSpl fisGVmsyPY//K5CaIg/UN7Fdergx/X497rRGTUUIRu4qKFmrVoV0VkLfklZ9BMVyZLoP RextF/2jGdJrvXxRLGlh3w/NZjiCSBnDt5YobD1NDDThIyk3QcHj7VAwcFp1WYZYiLQL kgiN4yn/24w873FoBruBG9sGrrNHiaJSd097kyR6xVrhSu01H+oIXbNLhUu+PBMd2bLC 52LA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=c6aABKpXMCHWTjg1I/aM1uM5Hh9/GIS1D4WV2556Mg4=; b=QkyodxlObVBMpMIW27w7WXkT0VQagNPKmFxJJCO7ajuviF4SiXoY2O/LtA8zjgyuD4 k7Mfu4bZbPjAF+tS1xE2KFE3PFD90hmNQaNBQ2umR26eMxCXJOX414yGWNBZVTnlcGCD YJLv5CbH6NkOcuIsu0+PWTB78Ox8uQnenJ/aiBSXAsEDlI/HYegvsgcWhu4S1ZlhDULI jrpRkygItenXuhAHi55WM+AFApACNDrsFb655YcfZmAR2n8cGBjy0rx03YUdpwBjSnNT n0YKUqmpUsttbRUivRFQ9ynej9EdzK5q3YNkNVY4iYz+lI+sQV5FmBsGZbHQL3GSbaGw trcQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=iObXXY1Q; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id w185si21343731qka.122.2019.10.24.10.21.22 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 24 Oct 2019 10:21:22 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=iObXXY1Q; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:48570 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNgnZ-0001Px-Oj for patch@linaro.org; Thu, 24 Oct 2019 13:21: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-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+patch=linaro.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(-) -- 2.20.1 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: 177596 Delivered-To: patch@linaro.org Received: by 2002:a92:409a:0:0:0:0:0 with SMTP id d26csp2497531ill; Thu, 24 Oct 2019 10:29:19 -0700 (PDT) X-Google-Smtp-Source: APXvYqwFQ7x5+OoPhiUsycko09gIOZzQwhOFiSeRXsDdvJgTEtgAf6oRhb8umHXdYrOtnskuOmcv X-Received: by 2002:a0c:8e04:: with SMTP id v4mr8170967qvb.98.1571938159333; Thu, 24 Oct 2019 10:29:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571938159; cv=none; d=google.com; s=arc-20160816; b=PD+mkWYCC1ak7tEbdnEXu9Lys2u3LXCQJj5sZSzRTwEySoXkUQA2tcEfW8wO/lsZ+K 1enpcrctxjUtk8IsN0pck+vndx3FVZmkpidE4kAKu6jM74z9gMTpl+sY4fAIoZbk45gi un0219sW85PNWJl5XlmLT5lJo1jpHOk/HNyoMJYOVY6j0FuVuTyv3OIajXaIGsTdLcRK +0sitfQrFgg+DAvhX+EKc6MFqrNBKtwtAPfbqCehINaG4oLo4gBxeYIdaXa60NEvpV8D 1H7vhU5mSPsd8caNk5HFHZG4ujuVRirBFV3R1VPK95m1PIUmUVR19qLzeK40lcjaaVRH c0pw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=PQl3KRLLMTqQVuIeb30pOMqlU1Q+h9n4TjUf1vQdg9c=; b=q+nWEAlHyVC+NPk/sr4/1g1oBAuJ0HIbHhvkNpHukz1SC2GSDaTHCcnjP4QdUn6IbL KdAI+srTclrUlwK4yvx9Y5Cp21BAw6F5LByKAZkIAHeRaQDE4xq/P2kWHezALpSMMjnL LydrdSNvN80SSgASi/ZG2dpWNJFcJXEXjkUzm+JAYOVl9NLOGRGlUNYqtvwTdKqg7YAa q/D4OLTU98Tsgevc7E8ryX9zAmQrdX9yfivxCbwxbT2N7Vovk3DY2EBdO7OS5YNVtYzg HexO93qw2lsf3KTnWNCoI89n9Hh5H1UzeWzeOlXqY+zGL35XSPejg1bqo9S9vzDFddIw UzeQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=fYmn6HIB; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id h18si9846962qvj.29.2019.10.24.10.29.19 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 24 Oct 2019 10:29:19 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=fYmn6HIB; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:48738 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNgvF-0003m2-W9 for patch@linaro.org; Thu, 24 Oct 2019 13:29:18 -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-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+patch=linaro.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(-) -- 2.20.1 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: 177597 Delivered-To: patch@linaro.org Received: by 2002:a92:409a:0:0:0:0:0 with SMTP id d26csp2498071ill; Thu, 24 Oct 2019 10:29:52 -0700 (PDT) X-Google-Smtp-Source: APXvYqwcwcH8oI1nPvE4iQlCAqevfnwkMRGlfrdZbUkMC12wt4VRnNiOMP11YUFGLSrtz5gwPeHo X-Received: by 2002:aed:24af:: with SMTP id t44mr4399508qtc.57.1571938192274; Thu, 24 Oct 2019 10:29:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571938192; cv=none; d=google.com; s=arc-20160816; b=xTms/TsR30rdvm9K+Cila0UgPJ3qvQD08lxEYI4SlqFTq7RPd6sY+5seq672E6gs1M ziL7zc5uidRmvajNHqoQ4RZslZzRbRHO/A5n47wyRs3kYhaOrLRQcOaaEEim4CmSMrsx XvWD6LLX0JOE2tRPKRH+xXuuBcpX7nJkZdEwHrIxm01y9iekOqgHRtHABQPp4Fjl4yH8 dw6b+AXsP5G6HJUqKMhMr1ewjnxy15mcx3a8mXyNmzbqx/XZ7NwESal1g/H9FN93Hg5P 0MrsVuyOLrjtqJcgcLsxPBMEAJBEN5dZ9qUSdd+2GAJZ5R+tr+WjS2cnKwpV/J+tRf0/ ZKiA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=DYAw+JFUSShxadh7hIyLKy0VSgftJwrYe33MmrE6aTY=; b=0YmALaF/gNAEonIZMXI1/nOg+fqjCTV0faiX6usIod3AMQHXTjYWpWlkZdRT0pH4F3 1i1+V7P9Tk6WlYrl0uPTrCisndIIuQyydbNHjfiYzg+whV+xw9q1HvPRkpAWJ8NWHBsQ QxW6vERAhd1xkDwYsz2a6HcnHcieQ20gBGmQj9EdNEYZS0y5UxNPcH/66PSYSlD+c6lf VzhF9WUkFzeEwbDN/K86Jj5JKrGAsouyBagA3SlvWToNxyojUT54fh3HITPpb8A7WM6P zTZtq6gwKcJ6LwwDwUuaz9KHJHerP4IHJr1o3LHH7zOXERgXBbKzIALQSi91Hr9XEutN FMIQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=M40LfjeE; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id r10si22833444qvd.142.2019.10.24.10.29.52 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 24 Oct 2019 10:29:52 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=M40LfjeE; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:48746 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNgvn-00043q-8a for patch@linaro.org; Thu, 24 Oct 2019 13:29:51 -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-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+patch=linaro.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(-) -- 2.20.1 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: 177599 Delivered-To: patch@linaro.org Received: by 2002:a92:409a:0:0:0:0:0 with SMTP id d26csp2503565ill; Thu, 24 Oct 2019 10:34:40 -0700 (PDT) X-Google-Smtp-Source: APXvYqzslwaiLDYc/0fBAn/BngZyzVksiVw8K/ZnkcBHeQgs46jW2uwcqwGddPzWfV8Frvuaap8B X-Received: by 2002:a50:af45:: with SMTP id g63mr43879217edd.21.1571938480507; Thu, 24 Oct 2019 10:34:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571938480; cv=none; d=google.com; s=arc-20160816; b=zP/mu0gna53CPZdE6hdtevlgfUGVMK3rMy6FQP3NPZTWnsKWtT9Z5rq4Sre/gs04JJ 6Xy3z8/TH2q8wRmUurHvtfpSMQKd9ZPsIROkwtJoq7s1lNlOjgDrROz7ysYrP/h7diHy aTZT14Bx09X2zKQYZs+8blaLxopy0q0j69cvIhNi/RavmCpe8946B6RhaN+4XQpgcZhf lY1W/DQFFfK5ZvIpd1qfqc/t3kcBJbNuWX7wEKRkWmyQhbuSJWF6mPqvAARNCarDqJW1 1k/WHCvqJAfDgttiCAGdoBfwV2n7vHAx8Ptdm6pf6HPAJ2p8CCqtkhe0RVKKMvq+19A/ AuHg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=1dJwftnWoG2W4EHlFbqacOwE41DkQDlktBfsa5t+Z30=; b=pbs9ZJA6KuGVlD05bpL/3zHhI45XNbGqO7qrZa0EwSRu8mjpjKBAB5+9MXUQNtYK6z lwosyvr3TsK/NH2mrxY9oY41QFOVyg54XkUzzUvL5Pq85yUbAL1mVCDioeYWMgHLdOmV OhRMMo4RR0wkrWcliaqhmOdC6/VvnPfO6XqYlBR7AbopBwmiTQRpEbuj/4WnCpsupwfi hSl3jLnGWqO73IyV06xQOon5cY3YR1XyTBX9U86wbwuvD7Q60sabgwn95KVHygLMb5kQ HVrsjiWtiBjkxiXTmG8ZieHV2L4xc50Qr7Yq5Nk0eSuq/A1jPZfewjaQXf4BPO5weG1s tqVg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=o+RzDBN+; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id m21si17860314edc.153.2019.10.24.10.34.40 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 24 Oct 2019 10:34:40 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=o+RzDBN+; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:48864 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNh0Q-0000B3-U3 for patch@linaro.org; Thu, 24 Oct 2019 13:34:38 -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-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+patch=linaro.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(-) -- 2.20.1 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: 177595 Delivered-To: patch@linaro.org Received: by 2002:a92:409a:0:0:0:0:0 with SMTP id d26csp2495723ill; Thu, 24 Oct 2019 10:27:37 -0700 (PDT) X-Google-Smtp-Source: APXvYqx00W3Si8oYN1eOVToRiudYwGd6wm8T3pB3iyXLQJDzuw1ItDWVsrqnC8BTKsIudUukBTsl X-Received: by 2002:a50:fe0f:: with SMTP id f15mr43624491edt.89.1571938057122; Thu, 24 Oct 2019 10:27:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571938057; cv=none; d=google.com; s=arc-20160816; b=k5MYcrExKhs++91uigU6rCG3qH9xhL016vj5Q4CpaIc0x6yGkDuqsmSiCRcV8T9e/q Tthsd6/pj/os1+L5G7LoWIR+Auo4CwesidiTvoUOMwSTahqUDaIp2rEtTJf2g6n1Jkyz WwlisE6snVRX4kIHHRG3M0pl5R0vKcrohMJdFIrzY4PmuShnrsgEwl6ldxVZCAykQGxk 593ATQequp+xv3HMWJDqqzQy385sxVE6Jp3sdzaUfOFo08hHNBBNz3bG1vELBMZd2y1k jFsX2uCfY+gQHG1LNy3tMooLEgVa+vfMwWH9+uJgY2xiCfq9Gy6KIzGgkMSrt6mvlfKh +mHA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=TW1rHEa4Yt+Clo9YX+nLhtNEgx47fDesU2q7Xi3+SMM=; b=n7mNgBIvU1OMK1Th+5FwymC50TYhZC7V/+FK2Mx2aLXxtxJvXdV+u4EIvCDTyQrKX0 b3OxnrSvMOGr+UXpaNCxdgitnJ7c4WYOPF/Ztprh0Nutg0MTo1EzqlZnWshxVy8m6F/K Uq6C2k6r82QGin3hw+CuXCGr5i1WqKH8WKs2BQQ1KfDL5GEz+vgLV7ucn94/AYQeogW9 WMd5KBHsIk08Ba/GSoY8MaybmHRWgy+2w6AyjPJ6+nF/fbAQTJWzmLJQeHh5rKFDPMf9 hlh5HxKpy125h5i6vJKhk7LzZXAPP0OQoYaHnAfy/LGWotOOZ7ud16W2ZMuUCdadsMpw hF2Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="IW1U/8Da"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id z22si15475220eji.413.2019.10.24.10.27.36 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 24 Oct 2019 10:27:37 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="IW1U/8Da"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:48720 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNgtb-0007FS-Gd for patch@linaro.org; Thu, 24 Oct 2019 13:27:35 -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-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+patch=linaro.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(-) -- 2.20.1 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)