From nobody Sat Apr 27 18:38:45 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1576852760; cv=none; d=zohomail.com; s=zohoarc; b=kQQT7pVprNLlbnhN/JnxYYBdYJ8d1gvWDnGyK0dV35ay3TCIV2DoJEdat2mrXTMthIydxOE+xAk3G6tJf6UfjRP+NZ6KvLOwHunUSz4cZp2iiJHb4lWix9pkLDnO6P7cgzslUL0tUWMG3UqDu6h/W1iBn+6Mfq+a8sqKaIRYN4M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1576852760; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=c8ReWNRJBR+WCHzBQj303nzzfEBRBdnQT57kHe9PFT0=; b=fFGd8eG+58oc7K58WXh85i3Ku+gd9T7M0Hr+oN963XXtTJO2m+YUZY53j449S6lvtfRQWEzf/QMSaR4ixm9co3QZpL0/EmNyXfuLyK36hAYHIIbbdFhtZfwDJpGQIIarl7L7QitUenKh1l5X7PXGQX6yb00dmBVeOwhDHeVpqOg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1576852760245206.76661676832396; Fri, 20 Dec 2019 06:39:20 -0800 (PST) Received: from localhost ([::1]:57354 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iiJR0-0006TD-T8 for importer@patchew.org; Fri, 20 Dec 2019 09:39:18 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:39886) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iiJEx-0004ft-Tx for qemu-devel@nongnu.org; Fri, 20 Dec 2019 09:26:52 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iiJEw-0006pi-7a for qemu-devel@nongnu.org; Fri, 20 Dec 2019 09:26:51 -0500 Received: from mail-wr1-x432.google.com ([2a00:1450:4864:20::432]:40620) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iiJEv-0006o8-TB for qemu-devel@nongnu.org; Fri, 20 Dec 2019 09:26:50 -0500 Received: by mail-wr1-x432.google.com with SMTP id c14so9584923wrn.7 for ; Fri, 20 Dec 2019 06:26:49 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id t5sm9741814wrr.35.2019.12.20.06.26.47 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Dec 2019 06:26:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=c8ReWNRJBR+WCHzBQj303nzzfEBRBdnQT57kHe9PFT0=; b=cwk9Xk5WU9GkbYSOc8QGDLSUZ5uIyWM+w2S/d5ed+yIwnmWUMeEF7KNaisXniPDy+2 yS8SjkEnABeMcBZPEPOxp347+YcqBT9S8/pmMoK4uRz8XgaFzZaW+to6GlEy809duxPv w2jRuGGLTLn35erjt6UdzowZRgyvT3YdtIki1ArBih3mbaM4axJJPVTIj+kcGgvZFC4w kK6RYIZx4lUjvf3tR42jt95OjlIzEIVLKO7z7qnxs7f7wMNefwUrl3f1gtjTgDHjhwXJ Gg2mp9i3ynqShurhNEPS4GPBwVWGPtyT/0jj68KcG39+c5sB1/3cmNJznqOMarkOx1Mc Rotw== 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=c8ReWNRJBR+WCHzBQj303nzzfEBRBdnQT57kHe9PFT0=; b=T4yeQjFJBTrG6IG/GGtPbxASWQEveZRGtDoazMgrMRezG10/B2yGpFGy8Y6Qd3FVvo ADL+ol/i/vqLb+EsEfvYS4WUcCCaK6+lsdvXPpj0fLapbLEpq4bZQBV187lGAE+kGVjC 1GhD/nZ8LgY0xaMX9wn9sMF0EgE8ubVrfMhbgGqhijYaDuhGsTSjMfQbV564e3tVQRZj eCZOxFUjjwTZvvF9VmL2hW9MnRhCZmFjvEz2kvgukEdDE35Cdb7eEiciqQCPTHH39T9B HSoF0EOYDEAAlBlEX5/jbUa5hbS2d7wRGC2lajXAhvOPRgayESMFP1O3MIFaB91Vj3ig 6+Yg== X-Gm-Message-State: APjAAAWq829UpUpO7g/c1GsEP8pkM0klY2aHo3ol0UKCClFWF/uPTA7b 5H5R9bmb3awCxWRdWRMXhJ5JHskBc0SP8A== X-Google-Smtp-Source: APXvYqwoYcIfkJKcPkD1QQdWqQ2XccG5Yjri4AFxvoMKtgCLiv60Kz8sJFSuThpEk2QHcjlbeYJseA== X-Received: by 2002:a05:6000:11c6:: with SMTP id i6mr15970969wrx.178.1576852008706; Fri, 20 Dec 2019 06:26:48 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 01/12] target/arm: Remove redundant scaling of nexttick Date: Fri, 20 Dec 2019 14:26:33 +0000 Message-Id: <20191220142644.31076-2-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191220142644.31076-1-peter.maydell@linaro.org> References: <20191220142644.31076-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) From: Andrew Jeffery The corner-case codepath was adjusting nexttick such that overflow wouldn't occur when timer_mod() scaled the value back up. Remove a use of GTIMER_SCALE and avoid unnecessary operations by calling timer_mod_ns() directly. Signed-off-by: Andrew Jeffery Reviewed-by: Richard Henderson Reviewed-by: C=C3=A9dric Le Goater Message-id: f8c680720e3abe55476e6d9cb604ad27fdbeb2e0.1576215453.git-series.= andrew@aj.id.au Signed-off-by: Peter Maydell --- target/arm/helper.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/target/arm/helper.c b/target/arm/helper.c index 5074b5f69ca..31fab098c55 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -2486,9 +2486,10 @@ static void gt_recalc_timer(ARMCPU *cpu, int timerid= x) * timer expires we will reset the timer for any remaining period. */ if (nexttick > INT64_MAX / GTIMER_SCALE) { - nexttick =3D INT64_MAX / GTIMER_SCALE; + timer_mod_ns(cpu->gt_timer[timeridx], INT64_MAX); + } else { + timer_mod(cpu->gt_timer[timeridx], nexttick); } - timer_mod(cpu->gt_timer[timeridx], nexttick); trace_arm_gt_recalc(timeridx, irqstate, nexttick); } else { /* Timer disabled: ISTATUS and timer output always clear */ --=20 2.20.1 From nobody Sat Apr 27 18:38:45 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1576852120; cv=none; d=zohomail.com; s=zohoarc; b=S0weGXTzNVNNDGbatRc5U5VNQDTvpSDQ+f8l8i01NCKF9Kb3t8Y3B5KCuEAYzjmZuzn3KPtyvB9EXXGmubMYowi9z3tXXqeznjwrrzgmvIlXuoROzmNUbHlPlhEC0eulMl+FagglvawM86iPyJdFVpdOzH2eRVkJ9oUui1njc4E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1576852120; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=GWiMxTEjs1K381f2nVjRWYY51/PQXmyOS4rDiBkvF/0=; b=eOgiwPjHnLOL9k/4LaQNv3ULIfZ+WtWyzuqxKWhMQv848WNZhGqlvhlfa+KD7XPzyN87y1zgaRFyIgqrboLOjXBRIxu+QI3Q0zRAokszQySjp6Wim5fR2wAjAdg2wb0hLJY7VsBglyMvz94Cto3gSzE6XsR3rcZTyABrp37EZ84= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1576852120410550.2311211005515; Fri, 20 Dec 2019 06:28:40 -0800 (PST) Received: from localhost ([::1]:57108 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iiJGg-0006h4-Dv for importer@patchew.org; Fri, 20 Dec 2019 09:28:38 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:40160) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iiJEz-0004kE-Pz for qemu-devel@nongnu.org; Fri, 20 Dec 2019 09:26:55 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iiJEx-0006rv-V4 for qemu-devel@nongnu.org; Fri, 20 Dec 2019 09:26:53 -0500 Received: from mail-wr1-x443.google.com ([2a00:1450:4864:20::443]:41229) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iiJEx-0006qK-K9 for qemu-devel@nongnu.org; Fri, 20 Dec 2019 09:26:51 -0500 Received: by mail-wr1-x443.google.com with SMTP id c9so9604649wrw.8 for ; Fri, 20 Dec 2019 06:26:51 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id t5sm9741814wrr.35.2019.12.20.06.26.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Dec 2019 06:26:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=GWiMxTEjs1K381f2nVjRWYY51/PQXmyOS4rDiBkvF/0=; b=kLnPJayxqP72w5mBX4IXo1EFXPA6KdNLdeY6v6EdNT0vwpclJIXpTSgUu24oa9nB3o S1bZlcUwhfO6M8yYiRV9FIxi9d/erbPS0YM15y2RZrLqFiYaITLPSqFZWjKbg+g+v+qw ex4p9M7Zj/XVObYEC5T3uoTa6jm5GUhsp5dBejb0QXFS0dETVbCzXQ9ubeL3aR0YyfU3 ImbstMQKTxuB6myWbWVWQq4E9u8KUtUjvY3Ehhicq/lP4XYlpgzZNBMZxW9mJJo3uJ6X BRHk3Sde8eRQoVrG3Fp5uNDvQyHZ+VF0lVUSbDpQb6/SlAUvdJNfaEnaL94Vgni6wRKZ IJaQ== 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=GWiMxTEjs1K381f2nVjRWYY51/PQXmyOS4rDiBkvF/0=; b=mSRWjD6asduSIDpJ0vX6YXQzNCXPvOkQtdInem7FMiOq4Xu0XNIYf+5Q3ipkvkB2IP zMtIIK7MXoYNNLNB2kShuSDF7rHk6W0yUmnI1/1EXwsGX12TrIxjoCNvMl2iwJkoor1M cp3ScJUQSAehMO5hxEUOSi5rXofQZfHVMzoTFwNYs9GC2fc1svQz/FaJuQCybmD1go6n cEMZ0cmL1EI3caH5ls201rZ0o9euC37plaKIVPUVQWFVBeHkzl2ZsS32ojGgXPKo+g8z w5Qt+AdV8YXecHdsOJxW2KeNBynyIE5etp9AupEj8NRQ+qsNKTrup6XgwccXmMuX0/nE xJWA== X-Gm-Message-State: APjAAAWUr2sn9OQps8tKuKpte5GtLIclc4e96KQ44t+s2iy5Z9Rbpa6v zalbUfB3hYPCf8GgBTErYvIwv67xLQpClA== X-Google-Smtp-Source: APXvYqw9rVIjfX44o1XXfAXzC3dMgGlpkXtEGgKnTwMotak4ie62XYTeg+oWalScQGGjTt3jPP+Hlw== X-Received: by 2002:adf:dfc1:: with SMTP id q1mr15493960wrn.155.1576852009870; Fri, 20 Dec 2019 06:26:49 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 02/12] target/arm: Abstract the generic timer frequency Date: Fri, 20 Dec 2019 14:26:34 +0000 Message-Id: <20191220142644.31076-3-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191220142644.31076-1-peter.maydell@linaro.org> References: <20191220142644.31076-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) From: Andrew Jeffery Prepare for SoCs such as the ASPEED AST2600 whose firmware configures CNTFRQ to values significantly larger than the static 62.5MHz value currently derived from GTIMER_SCALE. As the OS potentially derives its timer periods from the CNTFRQ value the lack of support for running QEMUTimers at the appropriate rate leads to sticky behaviour in the guest. Substitute the GTIMER_SCALE constant with use of a helper to derive the period from gt_cntfrq_hz stored in struct ARMCPU. Initially set gt_cntfrq_hz to the frequency associated with GTIMER_SCALE so current behaviour is maintained. Signed-off-by: Andrew Jeffery Reviewed-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daud=C3=A9 Message-id: 40bd8df043f66e1ccfb3e9482999d099ac72bb2e.1576215453.git-series.= andrew@aj.id.au Signed-off-by: Peter Maydell --- target/arm/cpu.h | 5 +++++ target/arm/cpu.c | 8 ++++++++ target/arm/helper.c | 10 +++++++--- 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/target/arm/cpu.h b/target/arm/cpu.h index 5f70e9e0438..40f2c45e17e 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -932,8 +932,13 @@ struct ARMCPU { */ DECLARE_BITMAP(sve_vq_map, ARM_MAX_VQ); DECLARE_BITMAP(sve_vq_init, ARM_MAX_VQ); + + /* Generic timer counter frequency, in Hz */ + uint64_t gt_cntfrq_hz; }; =20 +unsigned int gt_cntfrq_period_ns(ARMCPU *cpu); + void arm_cpu_post_init(Object *obj); =20 uint64_t arm_cpu_mp_affinity(int idx, uint8_t clustersz); diff --git a/target/arm/cpu.c b/target/arm/cpu.c index dd51adac059..0abe288e38c 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -974,6 +974,8 @@ static void arm_cpu_initfn(Object *obj) if (tcg_enabled()) { cpu->psci_version =3D 2; /* TCG implements PSCI 0.2 */ } + + cpu->gt_cntfrq_hz =3D NANOSECONDS_PER_SECOND / GTIMER_SCALE; } =20 static Property arm_cpu_reset_cbar_property =3D @@ -1055,6 +1057,12 @@ static void arm_set_init_svtor(Object *obj, Visitor = *v, const char *name, visit_type_uint32(v, name, &cpu->init_svtor, errp); } =20 +unsigned int gt_cntfrq_period_ns(ARMCPU *cpu) +{ + return NANOSECONDS_PER_SECOND > cpu->gt_cntfrq_hz ? + NANOSECONDS_PER_SECOND / cpu->gt_cntfrq_hz : 1; +} + void arm_cpu_post_init(Object *obj) { ARMCPU *cpu =3D ARM_CPU(obj); diff --git a/target/arm/helper.c b/target/arm/helper.c index 31fab098c55..85963789f7d 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -2449,7 +2449,9 @@ static CPAccessResult gt_stimer_access(CPUARMState *e= nv, =20 static uint64_t gt_get_countervalue(CPUARMState *env) { - return qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) / GTIMER_SCALE; + ARMCPU *cpu =3D env_archcpu(env); + + return qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) / gt_cntfrq_period_ns(cpu= ); } =20 static void gt_recalc_timer(ARMCPU *cpu, int timeridx) @@ -2485,7 +2487,7 @@ static void gt_recalc_timer(ARMCPU *cpu, int timeridx) * set the timer for as far in the future as possible. When the * timer expires we will reset the timer for any remaining period. */ - if (nexttick > INT64_MAX / GTIMER_SCALE) { + if (nexttick > INT64_MAX / gt_cntfrq_period_ns(cpu)) { timer_mod_ns(cpu->gt_timer[timeridx], INT64_MAX); } else { timer_mod(cpu->gt_timer[timeridx], nexttick); @@ -2914,11 +2916,13 @@ static const ARMCPRegInfo generic_timer_cp_reginfo[= ] =3D { =20 static uint64_t gt_virt_cnt_read(CPUARMState *env, const ARMCPRegInfo *ri) { + ARMCPU *cpu =3D env_archcpu(env); + /* Currently we have no support for QEMUTimer in linux-user so we * can't call gt_get_countervalue(env), instead we directly * call the lower level functions. */ - return cpu_get_clock() / GTIMER_SCALE; + return cpu_get_clock() / gt_cntfrq_period_ns(cpu); } =20 static const ARMCPRegInfo generic_timer_cp_reginfo[] =3D { --=20 2.20.1 From nobody Sat Apr 27 18:38:45 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1576852277; cv=none; d=zohomail.com; s=zohoarc; b=RR8A6xZhwHZaMU4n0JB7qOlycqmpoj38IAbjXf+z2vwi/hV/8TKOzXK8m2PCMXlUAbL3Lc5qO2FuZGSW58F6ufhfk3g3QgstHxxYF4nnqDCIJTV2Z2yUZDpcg/0FDQYYdV0FzAZoQVrMdzjljrToHZ2mY2udCG+17se9uFOlG48= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1576852277; h=Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Gbu+WbBDFzD2YgTHbagiyWS90NksqhC1RztZJbMJG+c=; b=b5HVwuVcqMukV8LOB5Px+MpZO3X+zvKDQp0UD2vNY3LsvUvsvxzYZlUYmw1RfptUb8JwWNDVVcJs7FM/EXOoX94yv7zHK1YOTHgnbHwk8OOjvU1ydqjdxr8CHQ4FnSdp5wo8vyoAOQGJ0wHBjhgOHOkeGHlCWQ62yeJB504FxSA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1576852277333789.3034244038521; Fri, 20 Dec 2019 06:31:17 -0800 (PST) Received: from localhost ([::1]:57178 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iiJJD-0002I1-RM for importer@patchew.org; Fri, 20 Dec 2019 09:31:15 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:40342) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iiJF1-0004lf-3G for qemu-devel@nongnu.org; Fri, 20 Dec 2019 09:26:56 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iiJEz-0006wi-36 for qemu-devel@nongnu.org; Fri, 20 Dec 2019 09:26:54 -0500 Received: from mail-wm1-x330.google.com ([2a00:1450:4864:20::330]:39376) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iiJEy-0006sC-Oa for qemu-devel@nongnu.org; Fri, 20 Dec 2019 09:26:52 -0500 Received: by mail-wm1-x330.google.com with SMTP id 20so9307770wmj.4 for ; Fri, 20 Dec 2019 06:26:52 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id t5sm9741814wrr.35.2019.12.20.06.26.49 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Dec 2019 06:26:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=Gbu+WbBDFzD2YgTHbagiyWS90NksqhC1RztZJbMJG+c=; b=YEJSnFI4rHJHkkUlL+1Ml3Pm5H4WquiC2tp6Q/MeePfsZX/geGWgpCNtonJSdgjX92 RUcAU+OW0WF5WB60lQrfE8GK/CbTRR4BXK2LaC3WhcrxYEFhGOVo6qcyZMalFL0iob+A co3n5wbfkN+HwPDoH6L5VFn2s2OUiDaImAgf0J9zIsBgd5Fq+vuaq/cBoM/OmepOdsKr dEYNznvfoDa62R8ktMM/GjN1ekiGr2t5HCda6f0pyantSnZmZ/OfLlex3Oq636N3WbkA EstKsHYTzQzK4JXJJq0eIULvpfSWsYCQEl0kBNw9jdfu8wnjrulZVUy9F2B+XIAPBj2d ltGw== 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=Gbu+WbBDFzD2YgTHbagiyWS90NksqhC1RztZJbMJG+c=; b=LWXtSQ9eO0Sp4YCdmF6zPvtURZxnJGJZAvW1wu/o6afUNwhoLMkV4biXfU8cAJaGaS 3v5vpQGNu020EFjmsvrXCcfol+yEav2cA4fHVE5cqCNBtsL6J3Kt63hOsX1V8qgFP9B9 4+uC6EYcW/N+m8MbQ3oeP/qc4fspYNeK2ZeHYgca/iODOUxibIRcNlEUDO2Hvkg389cZ xw3qUin7DoWl3pJojLm6IJfg3IHjpz7ag/hi5G2F6ZOyxg/OEveJQfUT/ZVdIjkrOLxi EyKNgXQVs3L7M7+RTpWieBHDIDuS5R2UHftdEiUfN9YUZbw0Ng+BOuX11uhLm24Bj8Ga J2qw== X-Gm-Message-State: APjAAAUhZj8Bf9vfdGspIZ6xtSsf/SnhFFeWUHeX0zES9rwujnJZRNgz wTHxLV5ItHhg1bPUWUIHjj4SIU3HjlCg3Q== X-Google-Smtp-Source: APXvYqzCtgb5DL3fmArXqzhfhZD8w7WiAto2pbjGg7CZO/mwT8rZoH5A4UxYjSaAblQITw0swyLISQ== X-Received: by 2002:a05:600c:218b:: with SMTP id e11mr15736508wme.121.1576852011095; Fri, 20 Dec 2019 06:26:51 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 03/12] target/arm: Prepare generic timer for per-platform CNTFRQ Date: Fri, 20 Dec 2019 14:26:35 +0000 Message-Id: <20191220142644.31076-4-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191220142644.31076-1-peter.maydell@linaro.org> References: <20191220142644.31076-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) Content-Type: text/plain; charset="utf-8" From: Andrew Jeffery The ASPEED AST2600 clocks the generic timer at the rate of HPLL. On recent firmwares this is at 1125MHz, which is considerably quicker than the assumed 62.5MHz of the current generic timer implementation. The delta between the value as read from CNTFRQ and the true rate of the underlying QEMUTimer leads to sticky behaviour in AST2600 guests. Add a feature-gated property exposing CNTFRQ for ARM CPUs providing the generic timer. This allows platforms to configure CNTFRQ (and the associated QEMUTimer) to the appropriate frequency prior to starting the guest. As the platform can now determine the rate of CNTFRQ we're exposed to limitations of QEMUTimer that didn't previously materialise: In the course of emulation we need to arbitrarily and accurately convert between guest ticks and time, but we're constrained by QEMUTimer's use of an integer scaling factor. The effect is QEMUTimer cannot exactly capture the period of frequencies that do not cleanly divide NANOSECONDS_PER_SECOND for scaling ticks to time. As such, provide an equally inaccurate scaling factor for scaling time to ticks so at least a self-consistent inverse relationship holds. Signed-off-by: Andrew Jeffery Reviewed-by: Richard Henderson Message-id: a22db9325f96e39f76e3c2baddcb712149f46bf2.1576215453.git-series.= andrew@aj.id.au Signed-off-by: Peter Maydell --- target/arm/cpu.c | 61 +++++++++++++++++++++++++++++++++++++-------- target/arm/helper.c | 9 ++++++- 2 files changed, 59 insertions(+), 11 deletions(-) diff --git a/target/arm/cpu.c b/target/arm/cpu.c index 0abe288e38c..d62fd5fdc64 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -974,10 +974,12 @@ static void arm_cpu_initfn(Object *obj) if (tcg_enabled()) { cpu->psci_version =3D 2; /* TCG implements PSCI 0.2 */ } - - cpu->gt_cntfrq_hz =3D NANOSECONDS_PER_SECOND / GTIMER_SCALE; } =20 +static Property arm_cpu_gt_cntfrq_property =3D + DEFINE_PROP_UINT64("cntfrq", ARMCPU, gt_cntfrq_hz, + NANOSECONDS_PER_SECOND / GTIMER_SCALE); + static Property arm_cpu_reset_cbar_property =3D DEFINE_PROP_UINT64("reset-cbar", ARMCPU, reset_cbar, 0); =20 @@ -1059,6 +1061,24 @@ static void arm_set_init_svtor(Object *obj, Visitor = *v, const char *name, =20 unsigned int gt_cntfrq_period_ns(ARMCPU *cpu) { + /* + * The exact approach to calculating guest ticks is: + * + * muldiv64(qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL), cpu->gt_cntfrq_= hz, + * NANOSECONDS_PER_SECOND); + * + * We don't do that. Rather we intentionally use integer division + * truncation below and in the caller for the conversion of host monot= onic + * time to guest ticks to provide the exact inverse for the semantics = of + * the QEMUTimer scale factor. QEMUTimer's scale facter is an integer,= so + * it loses precision when representing frequencies where + * `(NANOSECONDS_PER_SECOND % cpu->gt_cntfrq) > 0` holds. Failing to + * provide an exact inverse leads to scheduling timers with negative + * periods, which in turn leads to sticky behaviour in the guest. + * + * Finally, CNTFRQ is effectively capped at 1GHz to ensure our scale f= actor + * cannot become zero. + */ return NANOSECONDS_PER_SECOND > cpu->gt_cntfrq_hz ? NANOSECONDS_PER_SECOND / cpu->gt_cntfrq_hz : 1; } @@ -1180,6 +1200,11 @@ void arm_cpu_post_init(Object *obj) =20 qdev_property_add_static(DEVICE(obj), &arm_cpu_cfgend_property, &error_abort); + + if (arm_feature(&cpu->env, ARM_FEATURE_GENERIC_TIMER)) { + qdev_property_add_static(DEVICE(cpu), &arm_cpu_gt_cntfrq_property, + &error_abort); + } } =20 static void arm_cpu_finalizefn(Object *obj) @@ -1259,14 +1284,30 @@ static void arm_cpu_realizefn(DeviceState *dev, Err= or **errp) } } =20 - cpu->gt_timer[GTIMER_PHYS] =3D timer_new(QEMU_CLOCK_VIRTUAL, GTIMER_SC= ALE, - arm_gt_ptimer_cb, cpu); - cpu->gt_timer[GTIMER_VIRT] =3D timer_new(QEMU_CLOCK_VIRTUAL, GTIMER_SC= ALE, - arm_gt_vtimer_cb, cpu); - cpu->gt_timer[GTIMER_HYP] =3D timer_new(QEMU_CLOCK_VIRTUAL, GTIMER_SCA= LE, - arm_gt_htimer_cb, cpu); - cpu->gt_timer[GTIMER_SEC] =3D timer_new(QEMU_CLOCK_VIRTUAL, GTIMER_SCA= LE, - arm_gt_stimer_cb, cpu); + + { + uint64_t scale; + + if (arm_feature(env, ARM_FEATURE_GENERIC_TIMER)) { + if (!cpu->gt_cntfrq_hz) { + error_setg(errp, "Invalid CNTFRQ: %"PRId64"Hz", + cpu->gt_cntfrq_hz); + return; + } + scale =3D gt_cntfrq_period_ns(cpu); + } else { + scale =3D GTIMER_SCALE; + } + + cpu->gt_timer[GTIMER_PHYS] =3D timer_new(QEMU_CLOCK_VIRTUAL, scale, + arm_gt_ptimer_cb, cpu); + cpu->gt_timer[GTIMER_VIRT] =3D timer_new(QEMU_CLOCK_VIRTUAL, scale, + arm_gt_vtimer_cb, cpu); + cpu->gt_timer[GTIMER_HYP] =3D timer_new(QEMU_CLOCK_VIRTUAL, scale, + arm_gt_htimer_cb, cpu); + cpu->gt_timer[GTIMER_SEC] =3D timer_new(QEMU_CLOCK_VIRTUAL, scale, + arm_gt_stimer_cb, cpu); + } #endif =20 cpu_exec_realizefn(cs, &local_err); diff --git a/target/arm/helper.c b/target/arm/helper.c index 85963789f7d..1d9af2d8b28 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -2723,6 +2723,13 @@ void arm_gt_stimer_cb(void *opaque) gt_recalc_timer(cpu, GTIMER_SEC); } =20 +static void arm_gt_cntfrq_reset(CPUARMState *env, const ARMCPRegInfo *opaq= ue) +{ + ARMCPU *cpu =3D env_archcpu(env); + + cpu->env.cp15.c14_cntfrq =3D cpu->gt_cntfrq_hz; +} + static const ARMCPRegInfo generic_timer_cp_reginfo[] =3D { /* Note that CNTFRQ is purely reads-as-written for the benefit * of software; writing it doesn't actually change the timer frequency. @@ -2737,7 +2744,7 @@ static const ARMCPRegInfo generic_timer_cp_reginfo[] = =3D { .opc0 =3D 3, .opc1 =3D 3, .crn =3D 14, .crm =3D 0, .opc2 =3D 0, .access =3D PL1_RW | PL0_R, .accessfn =3D gt_cntfrq_access, .fieldoffset =3D offsetof(CPUARMState, cp15.c14_cntfrq), - .resetvalue =3D (1000 * 1000 * 1000) / GTIMER_SCALE, + .resetfn =3D arm_gt_cntfrq_reset, }, /* overall control: mostly access permissions */ { .name =3D "CNTKCTL", .state =3D ARM_CP_STATE_BOTH, --=20 2.20.1 From nobody Sat Apr 27 18:38:45 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1576852429; cv=none; d=zohomail.com; s=zohoarc; b=lumNvoZXqnFHZp6ZZ477O25rsDk45NbVkq1LSiA0JggVFQnZdGq0rCT4kEi5DQ2vYhvbXMO/GWqKmdlrnBO75bhRktsllaT5jXnxDSkhW5dwUQ5RCLGx3GTb5/8uJYdELxdhwemRExoBXVRzrxI1ou8mEdBfkjvx9ZRF/gQtTSs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1576852429; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=1Vvsojp+zl6N16RSn1fF9GlZuFxqm0kem6/eRYXK5FA=; b=V89DUlITNLE5/WDBnO4ZPUQ3MUkoFieX/pCMTQrnThk9+TQp8DS+EdCpkq6mwqgZXkHM5wKoSFehHVRyYIo5snFdwM8lReuJdAFkTUg3oljyBDxmR4q8Mu/Ns5f/4sK7Oc+F0Pc7gLZsa5GM+d5t+oCiG9O7yRTvzTUdTcaOfNY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 157685242961196.0750925001721; Fri, 20 Dec 2019 06:33:49 -0800 (PST) Received: from localhost ([::1]:57218 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iiJLf-0005Vu-MN for importer@patchew.org; Fri, 20 Dec 2019 09:33:47 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:40463) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iiJF1-0004mW-TL for qemu-devel@nongnu.org; Fri, 20 Dec 2019 09:26:56 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iiJF0-00072P-GT for qemu-devel@nongnu.org; Fri, 20 Dec 2019 09:26:55 -0500 Received: from mail-wm1-x343.google.com ([2a00:1450:4864:20::343]:54099) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iiJF0-0006yA-3p for qemu-devel@nongnu.org; Fri, 20 Dec 2019 09:26:54 -0500 Received: by mail-wm1-x343.google.com with SMTP id m24so9123783wmc.3 for ; Fri, 20 Dec 2019 06:26:54 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id t5sm9741814wrr.35.2019.12.20.06.26.51 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Dec 2019 06:26:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=1Vvsojp+zl6N16RSn1fF9GlZuFxqm0kem6/eRYXK5FA=; b=Xc0qI9gdlGukiYwgAhUlI+C+XgvtVMRW1Z8z9Ry4Bj91oUV8bhxw+r4ZT9jJ5ylqDb kPWthdk45dVEtNpjjWEfneuihy9SYy/UNmbwVKmhWE9L14hjBkHcZ+fqcWOjTZFih4Jx WZyAHcGJXwUVOJnGJP+0M3LwZmvzwvYvW951yoe3Wsn+6l9gtrQIahvqsZwXA+7Z+mxM 9RSXeO0EPjR14rV72bros9vLHbRJVIpP4XEXVWxfThGwfza33gSv7RBUz7x7yK4jkp1W 8ChmaPFY3oWkiWPwc49un7oZiKjVl6+N+aQG2pMmw70zOgIyPbMSn04PEkCmPCEaJmWC cePQ== 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=1Vvsojp+zl6N16RSn1fF9GlZuFxqm0kem6/eRYXK5FA=; b=FqePVdC1HjiRA9otYiDgTZs+3HjYvA59OhwYGWn9aHemMUq7H+3RrS/vlM3ctEOREn bUGZg531EHeH1bfxOj3+F0yzuw4GQVH7LU1goSsO6V7JQvC/U6CI7W7kLk8Cw7U9/rlM 6zLKSfDLn/zeVt84gsnQFVyIPLvoSBOzpobMyLWEJ7lyLyNFKRPpEuEhRTF9cg7ux4A9 s7l+AP4uI0XHj29DA+49fUrpRQ2t05ziZrhP5R/2ns7NZqoqv+bdSayL+f+ecQ/5U5tN GxM3C2TqLbS7nQCpkC3+ssp5wGmFujmYuHdHmckDMfaqxEaD7Rw2jQIbJzvLZOH9k8FZ /QfQ== X-Gm-Message-State: APjAAAXtxVUaIpQiGAqtswyyL/dGim3ck8YBdRA4TIdlHGTCxcg/iVbv N/J/+rBFSFfHTuo9+aH7e7UR7f3W8I/kpg== X-Google-Smtp-Source: APXvYqwVeeJJtIpXx5FzGHQTSiCAn7F7wr8ULFlxA6A9yr6Zh1t+ynWx1Whb5Je+JBRI/meRZv5ACw== X-Received: by 2002:a1c:770e:: with SMTP id t14mr17934164wmi.101.1576852012582; Fri, 20 Dec 2019 06:26:52 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 04/12] ast2600: Configure CNTFRQ at 1125MHz Date: Fri, 20 Dec 2019 14:26:36 +0000 Message-Id: <20191220142644.31076-5-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191220142644.31076-1-peter.maydell@linaro.org> References: <20191220142644.31076-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) From: Andrew Jeffery This matches the configuration set by u-boot on the AST2600. Signed-off-by: Andrew Jeffery Reviewed-by: Richard Henderson Reviewed-by: C=C3=A9dric Le Goater Reviewed-by: Philippe Mathieu-Daud=C3=A9 Message-id: 080ca1267a09381c43cf3c50d434fb6c186f2b6e.1576215453.git-series.= andrew@aj.id.au Signed-off-by: Peter Maydell --- hw/arm/aspeed_ast2600.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/hw/arm/aspeed_ast2600.c b/hw/arm/aspeed_ast2600.c index be88005dab8..89e4b009504 100644 --- a/hw/arm/aspeed_ast2600.c +++ b/hw/arm/aspeed_ast2600.c @@ -250,6 +250,9 @@ static void aspeed_soc_ast2600_realize(DeviceState *dev= , Error **errp) object_property_set_int(OBJECT(&s->cpu[i]), aspeed_calc_affinity(i= ), "mp-affinity", &error_abort); =20 + object_property_set_int(OBJECT(&s->cpu[i]), 1125000000, "cntfrq", + &error_abort); + /* * TODO: the secondary CPUs are started and a boot helper * is needed when using -kernel --=20 2.20.1 From nobody Sat Apr 27 18:38:45 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1576852536; cv=none; d=zohomail.com; s=zohoarc; b=P4cXk76lfBL0uA58H5q5DHwkNgMYk9Nsi0VHRoVhDVTZFzHosU3GqWywgYUdb5T5kBcR92zKkHbv/Uzmv0363MQmUFYqBmoLR0BZHg6E54LUebLw1TafsuBwFgN02PpNgEsYQIws3y2eOS+xEvSmeetJ6xbowRUZVKGMZVliHl8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1576852536; h=Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=woJz/eJmvbgXNcYcfQzwAYhmXMaSuqBNsrUl7dl2UT8=; b=a7Dt9eUVl7FFEWXylyqF9ARxuE/rU90nTqmo0S96UeuFhDs/o9WRImDGUGt6QZ8xTlqai5hY3ZWMMrBL41iWlveawH6XbRqCmhV8OmbCLkkZCXchb7SFD3qcQRGV/ZlahffqorLrxvktkfGDi5neDtCkjKMvjz13pBiKQdkYc5Y= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1576852536723706.9142446112317; Fri, 20 Dec 2019 06:35:36 -0800 (PST) Received: from localhost ([::1]:57258 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iiJNP-0000Cu-3w for importer@patchew.org; Fri, 20 Dec 2019 09:35:35 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:40644) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iiJF3-0004ns-3T for qemu-devel@nongnu.org; Fri, 20 Dec 2019 09:26:58 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iiJF1-00078g-SP for qemu-devel@nongnu.org; Fri, 20 Dec 2019 09:26:56 -0500 Received: from mail-wm1-x333.google.com ([2a00:1450:4864:20::333]:52386) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iiJF1-00073W-Iu for qemu-devel@nongnu.org; Fri, 20 Dec 2019 09:26:55 -0500 Received: by mail-wm1-x333.google.com with SMTP id p9so9138890wmc.2 for ; Fri, 20 Dec 2019 06:26:55 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id t5sm9741814wrr.35.2019.12.20.06.26.52 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Dec 2019 06:26:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=woJz/eJmvbgXNcYcfQzwAYhmXMaSuqBNsrUl7dl2UT8=; b=bkB8n4O0JGg+VztTag2t2tYr6kjshA9K5xLVexzKsUVvjjyQ1LSF1Ex5M8kJkfYQkU aslqLS2NvzoWFK+dqaNZHPVL6AnoRplPoaDR7GZE0PcdfH5q8T0Txh/20pKoU/BSllWq aE9uOWIHn4pjwEO1kk550QmAhiGqTHyKt9WjCeC2aaE8bpEbJGvd8vp2AJv6egj6u9w+ A4BLqxp+l58RvLURe20hks8aTMYm/Ro3f43DeqRwiOs0B1+bcrA0m9cBfZJYTV7Fc3fk Mam+l2e1tA4toGxva9QlYwL7R2av/oAM5+7LysR6dul/aP3XWysjvomszRpT+rjbEkbB X0/A== 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=woJz/eJmvbgXNcYcfQzwAYhmXMaSuqBNsrUl7dl2UT8=; b=kdci/t0jQyQ7/yOxjaQEa0ksdcPUFrW+tWqwZ7ylT+FPVcIcC2ZnJ8gnENlBI4I4p4 28KT4mf5EBuOPUGqaDZsv6ActFklKTh4WIIZkd1YDMy17FB7ZzkvZMN1Sgs79wJFCV+C V36IMObwcsygFBdnlP28n0c7BDP5SaoLOTmjBovyLUo4YozVmh6L0isIfr/aILhPVy5m qWZdrLHbSwl6U8R/HXVyvmmnpMtlWuYvnuXg6DThWLBNtrDB0IVV9AAP2BTibIkcftEX ZlE6AQ6qN9aW/5Z3LLvomkAiXcFu+QxjSBrb75NNVUxozp87MZp6E3uDo7bIbcI0Dh08 l+xg== X-Gm-Message-State: APjAAAU0XjCjYKWd3EtIYpdRbUABlJ2p1ltI7GafRgUR05ySh+STR3SV 8BQk4IkXaHmUaNrngYArnUq4SXLzV7ZfwA== X-Google-Smtp-Source: APXvYqwrh3J5I1N9Yno+qcYEIH1yDsvBc+QlSZjJ9K2YXss3fNsCvXNUObaP/iZcYUo/xtWWb6krvg== X-Received: by 2002:a1c:4b01:: with SMTP id y1mr16048592wma.12.1576852014072; Fri, 20 Dec 2019 06:26:54 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 05/12] hw/arm/smmuv3: Apply address mask to linear strtab base address Date: Fri, 20 Dec 2019 14:26:37 +0000 Message-Id: <20191220142644.31076-6-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191220142644.31076-1-peter.maydell@linaro.org> References: <20191220142644.31076-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::333 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) Content-Type: text/plain; charset="utf-8" From: Simon Veith In the SMMU_STRTAB_BASE register, the stream table base address only occupies bits [51:6]. Other bits, such as RA (bit [62]), must be masked out to obtain the base address. The branch for 2-level stream tables correctly applies this mask by way of SMMU_BASE_ADDR_MASK, but the one for linear stream tables does not. Apply the missing mask in that case as well so that the correct stream base address is used by guests which configure a linear stream table. Linux guests are unaffected by this change because they choose a 2-level stream table layout for the QEMU SMMUv3, based on the size of its stream ID space. ref. ARM IHI 0070C, section 6.3.23. Signed-off-by: Simon Veith Acked-by: Eric Auger Tested-by: Eric Auger Message-id: 1576509312-13083-2-git-send-email-sveith@amazon.de Cc: Eric Auger Cc: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org Acked-by: Eric Auger Reviewed-by: Peter Maydell Signed-off-by: Peter Maydell --- hw/arm/smmuv3.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/arm/smmuv3.c b/hw/arm/smmuv3.c index e2fbb8357ea..eef9a18d70f 100644 --- a/hw/arm/smmuv3.c +++ b/hw/arm/smmuv3.c @@ -429,7 +429,7 @@ static int smmu_find_ste(SMMUv3State *s, uint32_t sid, = STE *ste, } addr =3D l2ptr + l2_ste_offset * sizeof(*ste); } else { - addr =3D s->strtab_base + sid * sizeof(*ste); + addr =3D (s->strtab_base & SMMU_BASE_ADDR_MASK) + sid * sizeof(*st= e); } =20 if (smmu_get_ste(s, addr, ste, event)) { --=20 2.20.1 From nobody Sat Apr 27 18:38:45 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1576852123; cv=none; d=zohomail.com; s=zohoarc; b=eREHTqvLuomgUS9WaF7mIQrqSe7gbmyTDINzG35YEl1qs3V8ekuk70tvvy3/mTg/u49UamPGgsjGcsZKkW9B52SAaiW/yyZbCjz/Yd7b0ztwgCAnIwQitwXtcvyJtNu6fO46hN8dX+jYFcZ0G8PWsruaG8BXSSkgj4eosDHUyRQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1576852123; h=Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=BE5AXjPNjkWulE6XTqRNp3vD+tekVrRQDrvKnYuOy1Y=; b=XcugJvuN8WdC0ZREopxJMniWiwOfltwNE5hgVdDIYj4mzgkvKaMml+gwpDJqCGEdNEks0v9fv+s9EoSYGIfxwLUD29SzJyCJttfssPH8HUZy6gmh1y0NigV3xv9lS/BDAcMT6lpYyqGUHl/xMBi70T8xjt30GUOnYyoQjupdN9I= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 157685212353215.55430498735916; Fri, 20 Dec 2019 06:28:43 -0800 (PST) Received: from localhost ([::1]:57112 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iiJGk-0006mm-0Z for importer@patchew.org; Fri, 20 Dec 2019 09:28:42 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:40814) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iiJF4-0004pH-8c for qemu-devel@nongnu.org; Fri, 20 Dec 2019 09:26:59 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iiJF3-0007EF-1f for qemu-devel@nongnu.org; Fri, 20 Dec 2019 09:26:58 -0500 Received: from mail-wm1-x330.google.com ([2a00:1450:4864:20::330]:55443) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iiJF2-00079x-Mp for qemu-devel@nongnu.org; Fri, 20 Dec 2019 09:26:56 -0500 Received: by mail-wm1-x330.google.com with SMTP id q9so9139008wmj.5 for ; Fri, 20 Dec 2019 06:26:56 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id t5sm9741814wrr.35.2019.12.20.06.26.54 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Dec 2019 06:26:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=BE5AXjPNjkWulE6XTqRNp3vD+tekVrRQDrvKnYuOy1Y=; b=DT3P+bgqEdUzmnHE395fiAHLnqNucwlWj9mUZ3LOXvw9U493GaOWSe5bJWgVWIqhDM 9X9n+CKy5FN86ENWYQMv3tGiVIYursjGzEwRyYQB2sXG42ousDj4DFSVSRregSNyaX8V fhKaSxcjmm6aAb+OHV4u6F1tVEl+/n+5CwP/zV4V9fUuqBkmyxqXLalPq8BCEXBcup75 nxjyVx0bVlGhkE+a/Hb3eUsT94pYTok+HmRbTjf2nYjKKmfbZzbX5ptyuVuuCV5U7Nfh MmSj+QKP1ogf37gzEIg8rbRr978wQ6OOh/Tr9i73DgCLYfLsn5f8LvpXAsmVXWxahteL N0fQ== 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=BE5AXjPNjkWulE6XTqRNp3vD+tekVrRQDrvKnYuOy1Y=; b=ZD8uWpIDRQGfKMwoA8qxgEaM7C2Jq//6IIs2EOmK1GY0eaH4oGzW5JiP4e/fA1kg9I kMlztzyx7Zly5++DVDl67YgaPYMSCTkNRM1Ksbe2uN+Aewd5h0B05nemmw5e0oX051aS tlapdw3F3OIM2SrfAOQE3w1r8SJk/wuwtlH1x64p28q7WILKeRe4n8PriHZzBbldhIWs PUs5BstFoK+NWwa3KvfBgcINtlndIZvlZV0JNCUtqDZZDi0Ya3Js1HeTVbmQo2ui5EUK zVqqcqm0egkV/tI5w1tbOpIMMZJ1OjU6rxS/iqcgv60jGDtSSvdiCXWH0jO2qQrD/f+G bHpQ== X-Gm-Message-State: APjAAAXGFwVpZy4ZI+sXJIdiMwqBEiGY4Sp2lagfsxkz1n5Hums0aH8x LTPFLDxfZdhsWfFkUWAOXqfdztMFjAFnWw== X-Google-Smtp-Source: APXvYqya791ge1Xb3a6Pw8YorhCAVkWmmyPfYR1HzwzuD8oa0XyQtuN9lJlr4sVCX0+eG1LB5BnwxA== X-Received: by 2002:a1c:7c18:: with SMTP id x24mr16873295wmc.21.1576852015391; Fri, 20 Dec 2019 06:26:55 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 06/12] hw/arm/smmuv3: Correct SMMU_BASE_ADDR_MASK value Date: Fri, 20 Dec 2019 14:26:38 +0000 Message-Id: <20191220142644.31076-7-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191220142644.31076-1-peter.maydell@linaro.org> References: <20191220142644.31076-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) Content-Type: text/plain; charset="utf-8" From: Simon Veith There are two issues with the current value of SMMU_BASE_ADDR_MASK: - At the lower end, we are clearing bits [4:0]. Per the SMMUv3 spec, we should also be treating bit 5 as zero in the base address. - At the upper end, we are clearing bits [63:48]. Per the SMMUv3 spec, only bits [63:52] must be explicitly treated as zero. Update the SMMU_BASE_ADDR_MASK value to mask out bits [63:52] and [5:0]. ref. ARM IHI 0070C, section 6.3.23. Signed-off-by: Simon Veith Acked-by: Eric Auger Tested-by: Eric Auger Message-id: 1576509312-13083-3-git-send-email-sveith@amazon.de Cc: Eric Auger Cc: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org Reviewed-by: Peter Maydell Signed-off-by: Peter Maydell --- hw/arm/smmuv3-internal.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/arm/smmuv3-internal.h b/hw/arm/smmuv3-internal.h index d190181ef1b..042b4358084 100644 --- a/hw/arm/smmuv3-internal.h +++ b/hw/arm/smmuv3-internal.h @@ -99,7 +99,7 @@ REG32(GERROR_IRQ_CFG2, 0x74) =20 #define A_STRTAB_BASE 0x80 /* 64b */ =20 -#define SMMU_BASE_ADDR_MASK 0xffffffffffe0 +#define SMMU_BASE_ADDR_MASK 0xfffffffffffc0 =20 REG32(STRTAB_BASE_CFG, 0x88) FIELD(STRTAB_BASE_CFG, FMT, 16, 2) --=20 2.20.1 From nobody Sat Apr 27 18:38:45 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1576852129; cv=none; d=zohomail.com; s=zohoarc; b=WrgYxy17/BrdCpJMdrzmMfCZUKkQNigJnMyaYEMTgacT+Vk8t3lcZ6EVi6Y3T1Wfapwa48n2mtNSf+fU1+lFUDdd0kMNYw9XrKJgcM2ZCL0mFK0mR88IXeXY47HIsnsXhBwvODd0XoPIl0Mgk878l+YYcJ0d2lUexwbGVBARPig= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1576852129; h=Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=GrBrv5e7u4SPBOvAwKw188o0mEz5dyTHcixqY4buFoM=; b=cRzoL6hXlWfIVUO2ZA6VXxUQtitrqAHBWn/JhizAfIcuFE6wekEmUUWlgLnxZbwQsBMJlRYhw04mweM/c3/aS7HzO/tLpQzQBYmKX4IS2a0R3IaecczTZkzVb+7FN6207fJ+5xJrj/k/mxD8DcXFpI0FXi+5h120ruorZbHkcdI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1576852129343319.7570484770233; Fri, 20 Dec 2019 06:28:49 -0800 (PST) Received: from localhost ([::1]:57116 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iiJGp-0006vx-NK for importer@patchew.org; Fri, 20 Dec 2019 09:28:47 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:41078) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iiJF5-0004sB-Ul for qemu-devel@nongnu.org; Fri, 20 Dec 2019 09:27:02 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iiJF4-0007L0-L8 for qemu-devel@nongnu.org; Fri, 20 Dec 2019 09:26:59 -0500 Received: from mail-wm1-x333.google.com ([2a00:1450:4864:20::333]:51927) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iiJF4-0007HC-87 for qemu-devel@nongnu.org; Fri, 20 Dec 2019 09:26:58 -0500 Received: by mail-wm1-x333.google.com with SMTP id d73so9139592wmd.1 for ; Fri, 20 Dec 2019 06:26:58 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id t5sm9741814wrr.35.2019.12.20.06.26.55 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Dec 2019 06:26:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=GrBrv5e7u4SPBOvAwKw188o0mEz5dyTHcixqY4buFoM=; b=NV0jlGRe/1uoQSkWmTIsoO9O/PriK86L0iIm9x6RwdDXfFiPcW4Fx40c0/GLtfI1s3 irkg3K865O409QXT9F9q4coKg80QAAhGHa3adWnmue5/9nsu+TLkbu6Yr8Gl5b8HEJjq 9oh2fbI1cr+013vu9ihVLh9DJtzizjDRBWNHrfkCbaGCitdolI/xZVKQQGlS8nIVQzyB mv2ieWG85YZ1nZWcVzxDfFoVpaz1lib35jVs4bQa17NCjS/UuMBmQMlmV/Oh/4xVHJ67 jQ2tv90JwCTjEWoUWSXienW7UDsWT5OSGFDd5zerexVYo9tbpnO9kwdjE82IWnew8YSh WnOA== 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=GrBrv5e7u4SPBOvAwKw188o0mEz5dyTHcixqY4buFoM=; b=Une1NiQqONHMdW45nMuxQMpmgQeQNBp1oZaZCCW3obUiznMAEEbLqBoKRB4Fd4D/UG unY9RSobba0HTh4FC2CypV2XAj+NfgwBIwxQ8JgrUSoDBcU+LgGGZM3RCjL3QzRa93rc 4Isn98cht3ErgtIfgCkNOrKCW2O1sStUYAG29aG2IWyn9wYy9op3AjmfpT6HnILjmgy+ wiOwNtdCT+3tg3ESJiZ5R9PxbEQhM4sgAMeSuEqsDyUt0vr0jwYV8JTgBYS0LdXEqnPr I/V4SZk1xjty3kPSjMiAojITze/2iZRm/CUnXK6IPlaLX8+xS1X8csIs/qQKaSuk7lNr 0DLg== X-Gm-Message-State: APjAAAUxnqNJToeSR4g0P62r+ag7iAVU74FVzB86KVtrwJmXGSkdR8dt Bj/J7jkXnERy6IvO0GR13Cw2TFSfLSjEVQ== X-Google-Smtp-Source: APXvYqzRDo/gUfdnTtCzQDyY/6wj+HEM0q9Z08uflyCfsBRj7Yyt1Ev3es6RGI9ByVmbD1SIxeU69A== X-Received: by 2002:a1c:5f06:: with SMTP id t6mr16980412wmb.32.1576852016995; Fri, 20 Dec 2019 06:26:56 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 07/12] hw/arm/smmuv3: Check stream IDs against actual table LOG2SIZE Date: Fri, 20 Dec 2019 14:26:39 +0000 Message-Id: <20191220142644.31076-8-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191220142644.31076-1-peter.maydell@linaro.org> References: <20191220142644.31076-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::333 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) Content-Type: text/plain; charset="utf-8" From: Simon Veith When checking whether a stream ID is in range of the stream table, we have so far been only checking it against our implementation limit (SMMU_IDR1_SIDSIZE). However, the guest can program the STRTAB_BASE_CFG.LOG2SIZE field to a size that is smaller than this limit. Check the stream ID against this limit as well to match the hardware behavior of raising C_BAD_STREAMID events in case the limit is exceeded. Also, ensure that we do not go one entry beyond the end of the table by checking that its index is strictly smaller than the table size. ref. ARM IHI 0070C, section 6.3.24. Signed-off-by: Simon Veith Acked-by: Eric Auger Tested-by: Eric Auger Message-id: 1576509312-13083-4-git-send-email-sveith@amazon.de Cc: Eric Auger Cc: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org Reviewed-by: Peter Maydell Signed-off-by: Peter Maydell --- hw/arm/smmuv3.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/hw/arm/smmuv3.c b/hw/arm/smmuv3.c index eef9a18d70f..727558bcfa5 100644 --- a/hw/arm/smmuv3.c +++ b/hw/arm/smmuv3.c @@ -377,11 +377,15 @@ static int smmu_find_ste(SMMUv3State *s, uint32_t sid= , STE *ste, SMMUEventInfo *event) { dma_addr_t addr; + uint32_t log2size; int ret; =20 trace_smmuv3_find_ste(sid, s->features, s->sid_split); - /* Check SID range */ - if (sid > (1 << SMMU_IDR1_SIDSIZE)) { + log2size =3D FIELD_EX32(s->strtab_base_cfg, STRTAB_BASE_CFG, LOG2SIZE); + /* + * Check SID range against both guest-configured and implementation li= mits + */ + if (sid >=3D (1 << MIN(log2size, SMMU_IDR1_SIDSIZE))) { event->type =3D SMMU_EVT_C_BAD_STREAMID; return -EINVAL; } --=20 2.20.1 From nobody Sat Apr 27 18:38:45 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1576852276; cv=none; d=zohomail.com; s=zohoarc; b=e5gSBnoHACZ7jaUzIuCwwuLWEvQJfTul3CKEzQRKQe1SLWf8cH4AgHtb4mbiBBRFFs8byPB/2T+M/QB15uRQZ/jsnkFENqVoIYQjYs/J9UiZgakEVqDlJnKhtEFT3KjikIFgKHOF8FiwLbtQIc3V9vaHTwU2VEcxNMH4ANFepl8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1576852276; h=Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=2KUP15f7qeOWW1oxuca3zmV/3aT0vejsyXqh6o12C1s=; b=YyLQqPqXjhsOyNmqTM5zcB2uF1nYGBiHl87vJlMABFAUz+tbtsZHfbt+LiMNF2ziNbjEWu8LLqsr39nTPZ2fsrDUX0hZhUWKGjQdhL3FZAqMGtdyff/nVb9N8YB299dc5xq89QBlLZgq7SjYE3DHnFtc7N+4m+mSNbjjOFhSvvI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1576852276552598.8269948723686; Fri, 20 Dec 2019 06:31:16 -0800 (PST) Received: from localhost ([::1]:57174 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iiJJC-0002Hi-QC for importer@patchew.org; Fri, 20 Dec 2019 09:31:14 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:41386) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iiJF8-0004va-HU for qemu-devel@nongnu.org; Fri, 20 Dec 2019 09:27:03 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iiJF5-0007QG-VI for qemu-devel@nongnu.org; Fri, 20 Dec 2019 09:27:02 -0500 Received: from mail-wr1-x432.google.com ([2a00:1450:4864:20::432]:36929) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iiJF5-0007Li-HC for qemu-devel@nongnu.org; Fri, 20 Dec 2019 09:26:59 -0500 Received: by mail-wr1-x432.google.com with SMTP id w15so9634727wru.4 for ; Fri, 20 Dec 2019 06:26:59 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id t5sm9741814wrr.35.2019.12.20.06.26.57 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Dec 2019 06:26:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=2KUP15f7qeOWW1oxuca3zmV/3aT0vejsyXqh6o12C1s=; b=nwisGP7sTkpQRSQOd5ibYJljXAKb3ExWypM5ZSRaidLBclrPXBIRCY/pZi0gBnBxgq h8YQjAy0GbDY/v8NVfm7KVt+O1MxmJ9A9lTcaDYYLMiEgEHdd0/QfObjbTqu/VnqX7YG RPam1vL1cHlDp1fuQBRLR1a/7rmHWFcwHu356IU9WGke5XAGeZwoCP3Kx66B8rXikh4z f1pJSTOoS7O+eQn53OMr+sqBUlFi049b2cPsflzt/4ipcyKP3p749cDhR81kjvQ/F7ch jqVB9qgyQv9KMYpUAy0ruJ/iYFPLA2zMZRvf/wDxTTy95BOD8EeDkQrUfNN2qlctMkcB 3I7w== 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=2KUP15f7qeOWW1oxuca3zmV/3aT0vejsyXqh6o12C1s=; b=Wau0W30bUHabz9X3jJnk8LCEz9ZVl8Cu/vuD657357h0pQX9KaMBqTb5ep04xhO/9D liblpTgs5utNR72xKGMuK3chRx6XgQuDoVCrtm+jovucdVZodfqIaVbQD3IZwvI71RFD xuMMIN514MGFiz+fESKRk/7W/OyuMMiAVmYsyiEoF8Rulfr3zfDlX7gBtGGZEnh2xLSw 47+9zldMJQEO3PoNE6mQakf5zk8ezzusYhqNNWBWN7aWJtNL2Ng5Y0D/u9PnhvZ1UzYe mgWACjXL4UbpCJq+LQXvO0MPx17pGiQk5aRr3XJFYbSL0YixQ+gVeUHgmOI3/6ZPz/l2 lP4A== X-Gm-Message-State: APjAAAUcIbmJGc2GnwTPY9+J6/TAWwC2Tl0tdvcq/xN8cMKJRXZiC3/P St41j+fsZNjt0MOC8EqQ9BLaZh9gTMcW2A== X-Google-Smtp-Source: APXvYqyNjgZ64L/MbX+DQ6HqvYld7yo8L2xt/Y3+Uo6vInIDksE0vl7J3M30kB7pbOesLp9Wy7Xx+Q== X-Received: by 2002:adf:ea8a:: with SMTP id s10mr15258900wrm.278.1576852018159; Fri, 20 Dec 2019 06:26:58 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 08/12] hw/arm/smmuv3: Align stream table base address to table size Date: Fri, 20 Dec 2019 14:26:40 +0000 Message-Id: <20191220142644.31076-9-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191220142644.31076-1-peter.maydell@linaro.org> References: <20191220142644.31076-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) Content-Type: text/plain; charset="utf-8" From: Simon Veith Per the specification, and as observed in hardware, the SMMUv3 aligns the SMMU_STRTAB_BASE address to the size of the table by masking out the respective least significant bits in the ADDR field. Apply this masking logic to our smmu_find_ste() lookup function per the specification. ref. ARM IHI 0070C, section 6.3.23. Signed-off-by: Simon Veith Acked-by: Eric Auger Tested-by: Eric Auger Message-id: 1576509312-13083-5-git-send-email-sveith@amazon.de Cc: Eric Auger Cc: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org Reviewed-by: Peter Maydell Signed-off-by: Peter Maydell --- hw/arm/smmuv3.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/hw/arm/smmuv3.c b/hw/arm/smmuv3.c index 727558bcfa5..31ac3ca32eb 100644 --- a/hw/arm/smmuv3.c +++ b/hw/arm/smmuv3.c @@ -376,8 +376,9 @@ bad_ste: static int smmu_find_ste(SMMUv3State *s, uint32_t sid, STE *ste, SMMUEventInfo *event) { - dma_addr_t addr; + dma_addr_t addr, strtab_base; uint32_t log2size; + int strtab_size_shift; int ret; =20 trace_smmuv3_find_ste(sid, s->features, s->sid_split); @@ -391,10 +392,16 @@ static int smmu_find_ste(SMMUv3State *s, uint32_t sid= , STE *ste, } if (s->features & SMMU_FEATURE_2LVL_STE) { int l1_ste_offset, l2_ste_offset, max_l2_ste, span; - dma_addr_t strtab_base, l1ptr, l2ptr; + dma_addr_t l1ptr, l2ptr; STEDesc l1std; =20 - strtab_base =3D s->strtab_base & SMMU_BASE_ADDR_MASK; + /* + * Align strtab base address to table size. For this purpose, assu= me it + * is not bounded by SMMU_IDR1_SIDSIZE. + */ + strtab_size_shift =3D MAX(5, (int)log2size - s->sid_split - 1 + 3); + strtab_base =3D s->strtab_base & SMMU_BASE_ADDR_MASK & + ~MAKE_64BIT_MASK(0, strtab_size_shift); l1_ste_offset =3D sid >> s->sid_split; l2_ste_offset =3D sid & ((1 << s->sid_split) - 1); l1ptr =3D (dma_addr_t)(strtab_base + l1_ste_offset * sizeof(l1std)= ); @@ -433,7 +440,10 @@ static int smmu_find_ste(SMMUv3State *s, uint32_t sid,= STE *ste, } addr =3D l2ptr + l2_ste_offset * sizeof(*ste); } else { - addr =3D (s->strtab_base & SMMU_BASE_ADDR_MASK) + sid * sizeof(*st= e); + strtab_size_shift =3D log2size + 5; + strtab_base =3D s->strtab_base & SMMU_BASE_ADDR_MASK & + ~MAKE_64BIT_MASK(0, strtab_size_shift); + addr =3D strtab_base + sid * sizeof(*ste); } =20 if (smmu_get_ste(s, addr, ste, event)) { --=20 2.20.1 From nobody Sat Apr 27 18:38:45 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1576852427; cv=none; d=zohomail.com; s=zohoarc; b=NQL7NNMek7YyZZJiDtcH61HiizSo8cemv1qgoOGwE1hMKyLZwVo7HZaPBvYOtEvg65LlvMWPnlpjsXarhCKC9T87alrdywpDezqXFR0QhHc+tO+cYH6krPpF2TEHs27CN/CeNtf84kYzgyKpOrzIYBmdUSYD/MmmzeSMlaHAjoM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1576852427; h=Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Lo7PUw1ERbHRyrus/NtQMRXglB5e3q+im5wQRdibHpo=; b=GsrVsrXWdqtbo6ach7lzbBzTMM4rOweIFlpTLuBJ5mJh1m8lDu87iWF8JnfmR64akQydWzjo/tVFKiscRzXHmBvVv09MD70R4hfTAO5OnzF88glAztqhBvQH55fX83Tlm3tDd73dSV1nkN75zVxTZ0uecRYQJpP45hVCYe/eooM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1576852427756472.6621735489937; Fri, 20 Dec 2019 06:33:47 -0800 (PST) Received: from localhost ([::1]:57212 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iiJLd-0005RX-R9 for importer@patchew.org; Fri, 20 Dec 2019 09:33:45 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:41591) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iiJF9-0004xc-Vv for qemu-devel@nongnu.org; Fri, 20 Dec 2019 09:27:05 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iiJF8-0007ZW-GB for qemu-devel@nongnu.org; Fri, 20 Dec 2019 09:27:03 -0500 Received: from mail-wm1-x32d.google.com ([2a00:1450:4864:20::32d]:55441) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iiJF8-0007Rj-6B for qemu-devel@nongnu.org; Fri, 20 Dec 2019 09:27:02 -0500 Received: by mail-wm1-x32d.google.com with SMTP id q9so9139266wmj.5 for ; Fri, 20 Dec 2019 06:27:00 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id t5sm9741814wrr.35.2019.12.20.06.26.58 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Dec 2019 06:26:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=Lo7PUw1ERbHRyrus/NtQMRXglB5e3q+im5wQRdibHpo=; b=jgGbRcOUMiW7l8/UU/fw/TiMf/wyeqYA6yPJmKQLMpmauK3e0oWWa4ppOFgDKh7bZ5 V3rzZbYmD9474kGA2YQzRebe9pEEiWTiXRrSYwKdn8y7Z9kzB+b7FgdIHHXzqWeE41Py bb7oGXddS6bp/UOMXxpl1vhmM0mBzKXuesfZDNVXIpkakQ3jfxYxdOQRPGUzI4+gyIGA iqzim2Q/iT4zj1YAyAgE+CNkWOgPNiV7miKRTShDbN1j7QdZ3E10lkH7cwVSzhfQOsVv bYi9WYyQ4d5ZIjjxY54D9HoQRWcbYDRLxsGAsYY8SPZ9PLI8IH14TKxSBZUg7eEPGqCj 9jfQ== 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=Lo7PUw1ERbHRyrus/NtQMRXglB5e3q+im5wQRdibHpo=; b=evuFTFVsAE8kYRLkvdz4zUagByVUWP6Ug8mC6vrMPf2iACUymUX1qtWaqTMgPbvUCu jUpA3wj/0hP8mUFNuRtSyJ8a2UMKbkugfNaaRwST0/elCX/lqACbFTCaH9UBCJExWUSS lC5aBeSqEx2ndTJttPdSqXqAydsrX2BtfGxcs+/ffZBu+ATziUuB+y1QyEYJUJi1Nq/5 Sk18S7E6GjpZgfavOBQm7iSW5d/C8Ene1Mvq5jMMangJcIpQIHuaez/UEUmth9ZG9Hi2 BDFotra7exb2la6+0kmuhRL4q5Ser1RWMMwwrqanDrFrhULNTRfJTGW49kzKDtCZwFQE DvXQ== X-Gm-Message-State: APjAAAU//HeBp43/5Vf/Lo/cfoDLdoG4WVuP9hdogK4pwJtAjgBb/pBG /TXlD0YHsqUcD7Ra6UoWAUXc1IUlo1YDtg== X-Google-Smtp-Source: APXvYqy3PVMRLCOdt8JGn+/z7DMPTiFGVV+UzXPIL3JmX10hrxH7l9ly0XRoaUmEMq1B2P9SAlOSrA== X-Received: by 2002:a05:600c:218b:: with SMTP id e11mr15737180wme.121.1576852019796; Fri, 20 Dec 2019 06:26:59 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 09/12] hw/arm/smmuv3: Use correct bit positions in EVT_SET_ADDR2 macro Date: Fri, 20 Dec 2019 14:26:41 +0000 Message-Id: <20191220142644.31076-10-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191220142644.31076-1-peter.maydell@linaro.org> References: <20191220142644.31076-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) Content-Type: text/plain; charset="utf-8" From: Simon Veith The bit offsets in the EVT_SET_ADDR2 macro do not match those specified in the ARM SMMUv3 Architecture Specification. In all events that use this macro, e.g. F_WALK_EABT, the faulting fetch address or IPA actually occupies the 32-bit words 6 and 7 in the event record contiguously, with the upper and lower unused bits clear due to alignment or maximum supported address bits. How many bits are clear depends on the individual event type. Update the macro to write to the correct words in the event record so that guest drivers can obtain accurate address information on events. ref. ARM IHI 0070C, sections 7.3.12 through 7.3.16. Signed-off-by: Simon Veith Acked-by: Eric Auger Tested-by: Eric Auger Message-id: 1576509312-13083-6-git-send-email-sveith@amazon.de Cc: Eric Auger Cc: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org Acked-by: Eric Auger Reviewed-by: Peter Maydell Signed-off-by: Peter Maydell --- hw/arm/smmuv3-internal.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/arm/smmuv3-internal.h b/hw/arm/smmuv3-internal.h index 042b4358084..4112394129e 100644 --- a/hw/arm/smmuv3-internal.h +++ b/hw/arm/smmuv3-internal.h @@ -461,8 +461,8 @@ typedef struct SMMUEventInfo { } while (0) #define EVT_SET_ADDR2(x, addr) \ do { \ - (x)->word[7] =3D deposit32((x)->word[7], 3, 29, addr >> 16); = \ - (x)->word[7] =3D deposit32((x)->word[7], 0, 16, addr & 0xffff)= ;\ + (x)->word[7] =3D (uint32_t)(addr >> 32); \ + (x)->word[6] =3D (uint32_t)(addr & 0xffffffff); \ } while (0) =20 void smmuv3_record_event(SMMUv3State *s, SMMUEventInfo *event); --=20 2.20.1 From nobody Sat Apr 27 18:38:45 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1576852923; cv=none; d=zohomail.com; s=zohoarc; b=KlGYghZq7LtcoTzUBiwe3BgdcHQt9qLNoUAV4GzFFuiHiPHl+CPkstFWxjtfoMt/CGmcXjTQGGw6ncCKQP6wyNGY6b4tBbupNJv2IIHUI2+7kOMkpxvsGPg1crwCNVrRWtAOUiUHhn9IkMW4qb6ACBPlcj5T5Jr/yTCQourPdsw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1576852923; h=Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=WZI/13hDCT0fjFRzl2cTIlf4noZlFhqAIkSEplRevfg=; b=mDMOcK+BPqfzEGMI4n9qfc3N0257lxLJFYjvlpE0J26DbRmyw/3NM5jNu0loXHqWoFKcIe3hsVbEKlMlZ1Hx1e1Tkq5Wx4vr7EN5W1+TpV+l4yIZBczPp/kjdQwmZlk9oXXLLPr0cBrdnarAoL1ny3Na/6+WEvkzakNviLOTpfk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1576852923195197.11276083939606; Fri, 20 Dec 2019 06:42:03 -0800 (PST) Received: from localhost ([::1]:57416 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iiJTe-0001Pb-2c for importer@patchew.org; Fri, 20 Dec 2019 09:42:02 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:41593) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iiJF9-0004xe-Vt for qemu-devel@nongnu.org; Fri, 20 Dec 2019 09:27:05 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iiJF8-0007Zh-J2 for qemu-devel@nongnu.org; Fri, 20 Dec 2019 09:27:03 -0500 Received: from mail-wm1-x333.google.com ([2a00:1450:4864:20::333]:37710) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iiJF8-0007Ug-6E for qemu-devel@nongnu.org; Fri, 20 Dec 2019 09:27:02 -0500 Received: by mail-wm1-x333.google.com with SMTP id f129so9434446wmf.2 for ; Fri, 20 Dec 2019 06:27:01 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id t5sm9741814wrr.35.2019.12.20.06.26.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Dec 2019 06:27:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=WZI/13hDCT0fjFRzl2cTIlf4noZlFhqAIkSEplRevfg=; b=srUpsPMlg5gFrn06gUCIoOXh6sETLJIP7oNITjY5LITZ4o6hCZJXTVzona6erGujzh JrOWvcTI6sm7Xh/VJCUo3wPX0wkSJrKsqE1VWvU4feSN0tCAU48Ycdn5/nGI856GOr2d lieNJ6Si6BaCBpx1G5Cepl9CY+vzWwIjZWz21zkud0oZ+7LyNXmoI38boGG+XzSmrmhX c5WdrPuKXb8M5zFbUjDrRPqOfVLhE3jETWcNFlaa/mMfIqOfEiiiOnB9l8vv3Yko9gDq zgDaM9AbJpqkdkc32VqyVpVgXu8VgNwUspQRdmopzdnYpezfdniLQe5r7uj9vw92Brwi q9Qw== 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=WZI/13hDCT0fjFRzl2cTIlf4noZlFhqAIkSEplRevfg=; b=lXoF5yddV60AEyc1RbfiyUrmPBxrel0l34dX08npsL/eGCafEtzwZePaBxtWMo2EN8 +VQ6lZcw0rh36Q9JUc5aXWG7Syk8OF6b142j7j/DpMy1mCugQX+Yi+CwjPlRy23BW/Iv XARTxF2Nr3kJS4z6zNAsbGLmweY3rP7F30rnqG842TIjlO9cbHHyQCQj3CkNYrM9AEed fSY9fCwGfY0kl/qA+E4ZmBdKu1cGdDPvBcSUSX1Ewslkcyg9lzQfyg7H3Z02r2RYx8Q2 kZjoGnW3cPSIGzoFP/OqMTfEruHjpv6hY1YOCvJsjo23gY49P3/Fc8nuxcwRRdMejPTi jGSg== X-Gm-Message-State: APjAAAWv4G6aCsTzuQZM9VSegy/oFFkQL/BKKF1iSrbRPfnIR0M0+sQd S1axWZilgBmf4gmYlskrF2L04Sz5B8AoQQ== X-Google-Smtp-Source: APXvYqz4CB4e7QfykI0zuZ9nWUzbw7kpOxOFFFvEXau47d9HLC/x2ahzFuGf4L1BanuYPrOeJQ1oXg== X-Received: by 2002:a1c:1fd0:: with SMTP id f199mr16893618wmf.113.1576852020839; Fri, 20 Dec 2019 06:27:00 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 10/12] hw/arm/smmuv3: Report F_STE_FETCH fault address in correct word position Date: Fri, 20 Dec 2019 14:26:42 +0000 Message-Id: <20191220142644.31076-11-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191220142644.31076-1-peter.maydell@linaro.org> References: <20191220142644.31076-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::333 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) Content-Type: text/plain; charset="utf-8" From: Simon Veith The smmuv3_record_event() function that generates the F_STE_FETCH error uses the EVT_SET_ADDR macro to record the fetch address, placing it in 32-bit words 4 and 5. The correct position for this address is in words 6 and 7, per the SMMUv3 Architecture Specification. Update the function to use the EVT_SET_ADDR2 macro instead, which is the macro intended for writing to these words. ref. ARM IHI 0070C, section 7.3.4. Signed-off-by: Simon Veith Acked-by: Eric Auger Tested-by: Eric Auger Message-id: 1576509312-13083-7-git-send-email-sveith@amazon.de Cc: Eric Auger Cc: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org Acked-by: Eric Auger Reviewed-by: Peter Maydell Signed-off-by: Peter Maydell --- hw/arm/smmuv3.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/arm/smmuv3.c b/hw/arm/smmuv3.c index 31ac3ca32eb..8b5f157dc70 100644 --- a/hw/arm/smmuv3.c +++ b/hw/arm/smmuv3.c @@ -172,7 +172,7 @@ void smmuv3_record_event(SMMUv3State *s, SMMUEventInfo = *info) case SMMU_EVT_F_STE_FETCH: EVT_SET_SSID(&evt, info->u.f_ste_fetch.ssid); EVT_SET_SSV(&evt, info->u.f_ste_fetch.ssv); - EVT_SET_ADDR(&evt, info->u.f_ste_fetch.addr); + EVT_SET_ADDR2(&evt, info->u.f_ste_fetch.addr); break; case SMMU_EVT_C_BAD_STE: EVT_SET_SSID(&evt, info->u.c_bad_ste.ssid); --=20 2.20.1 From nobody Sat Apr 27 18:38:45 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1576852986; cv=none; d=zohomail.com; s=zohoarc; b=Zp/++H9yRqGKGjn+cl0dQ5DAFwQy0jGgZMzZeE3Mj5D3yUiNPKRfix5jcseKI5GGash/1JD/UVJk74AI0hbt1ZahldtJwxc4dUVka+zK6ynFzDklV/OjbYYnN2bkEEjECFJs5lpLuLn6kEkm5pTffBpFTjaIMdRF13XUQPRYBW4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1576852986; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=2N9BzGwQFOYr5kHxYpTN+kd6izVO1fNFifpaACJFB1U=; b=IHLu1TmoVFwe14HrmNKY25Uy2Mhh0un8zUy7GBNyUPAIrCkIePndxUU68QJ1QuiDueObPxQFiRLXpSwCI7BQWStrtbtncugYpc4NE3AHkc/kxenCWx6zWS+ufekHqp3pGnjzW123LYe1ASve6+qXQ3TmBuHgAFNjvbnmw4Ho0C8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1576852986117637.5891874695205; Fri, 20 Dec 2019 06:43:06 -0800 (PST) Received: from localhost ([::1]:57430 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iiJUf-0002Iw-01 for importer@patchew.org; Fri, 20 Dec 2019 09:43:05 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:41793) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iiJFB-0004zQ-2M for qemu-devel@nongnu.org; Fri, 20 Dec 2019 09:27:06 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iiJF9-0007eJ-Sl for qemu-devel@nongnu.org; Fri, 20 Dec 2019 09:27:04 -0500 Received: from mail-wm1-x336.google.com ([2a00:1450:4864:20::336]:37713) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iiJF9-0007ZI-AQ for qemu-devel@nongnu.org; Fri, 20 Dec 2019 09:27:03 -0500 Received: by mail-wm1-x336.google.com with SMTP id f129so9434498wmf.2 for ; Fri, 20 Dec 2019 06:27:03 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id t5sm9741814wrr.35.2019.12.20.06.27.00 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Dec 2019 06:27:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=2N9BzGwQFOYr5kHxYpTN+kd6izVO1fNFifpaACJFB1U=; b=j1NgWtewVyE+Q88aXnorv9zlUssDLuYOEx13FW5XRb12iH+PR+4RGNB6Hpcx04icXp ZCVKRbVVB7MYrRE8+j3+f4uXthmRQfDAp30aL2eaXiUr/xjJCpkVWfGvWVvcXDmdEswV TyKu7jiQyMsUCrxYF6freFrA3EAWlzLXAexV/Ma2gM/zy+8Joii4+5h+rABHP7fKXjJc W5VufREj1zP7ClDQXw87IPIfisYf/HbRU68muF2URAe01Ym7FqQJRQsrC6Wfx1vBCF2m neSaSYJBtiv12L3gPMRbAXTuHNhcFPG/YCgZTL0Y5Vvg+L3meZQFjgPxdXFykkoUbAK+ Ly5A== 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=2N9BzGwQFOYr5kHxYpTN+kd6izVO1fNFifpaACJFB1U=; b=EuZQflqO1UKpvIPKsJvyXFFYGK34YqHDsUkiFm25U61CPAOHoc7VVCoDIMlNy7y+lz 5P06LHpst0Lj4mpOcZLF4pc/PTKW1MRIHK5VVOeCY9ora58Wow4Jf2Oq2WpmS9gVFUKX kLUnJSVVGm5V37+K3578P8woARt6JU5zF3V0uvsnUpTsooCuxCnwm8NGtTT6NvK3U9ey a04Ktsz9h49IdR3dm2KnMtZSOWZXlhaTbnoJhS9JTvJ2FxKEeXjxJEsbS44FuEuMIxad vR61IPwipQ9D2igqWVmx3A5SJEY1R+SzBXdMN9fWdSprYTjIVfWWfZcq7OybtkpxfHOA tnJA== X-Gm-Message-State: APjAAAWBidODtwDY6N9j/eA8Jznj3A67VqcW1uGGVe4yWqwHBXp4sCzX AUg7GbV1m9GhbzHYt18OpPZtRnQAfaB3jg== X-Google-Smtp-Source: APXvYqzfdsioNL1SwOi9p4cBKoMlX7H3R9eyYqDCyVxK1eOnA3VakBEOAsJEZcd+7TEtXNWF0lOuXw== X-Received: by 2002:a1c:638a:: with SMTP id x132mr17978957wmb.43.1576852021797; Fri, 20 Dec 2019 06:27:01 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 11/12] target/arm: Display helpful message when hflags mismatch Date: Fri, 20 Dec 2019 14:26:43 +0000 Message-Id: <20191220142644.31076-12-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191220142644.31076-1-peter.maydell@linaro.org> References: <20191220142644.31076-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::336 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) From: Philippe Mathieu-Daud=C3=A9 Instead of crashing in a confuse way, give some hint to the user about why we aborted. He might report the issue without having to use a debugger. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Message-id: 20191209134552.27733-1-philmd@redhat.com Reviewed-by: Richard Henderson Tested-by: Niek Linnenbank Signed-off-by: Peter Maydell --- target/arm/helper.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/target/arm/helper.c b/target/arm/helper.c index 1d9af2d8b28..b6bec42f48e 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -11512,6 +11512,20 @@ void HELPER(rebuild_hflags_a64)(CPUARMState *env, = int el) env->hflags =3D rebuild_hflags_a64(env, el, fp_el, mmu_idx); } =20 +static inline void assert_hflags_rebuild_correctly(CPUARMState *env) +{ +#ifdef CONFIG_DEBUG_TCG + uint32_t env_flags_current =3D env->hflags; + uint32_t env_flags_rebuilt =3D rebuild_hflags_internal(env); + + if (unlikely(env_flags_current !=3D env_flags_rebuilt)) { + fprintf(stderr, "TCG hflags mismatch (current:0x%08x rebuilt:0x%08= x)\n", + env_flags_current, env_flags_rebuilt); + abort(); + } +#endif +} + void cpu_get_tb_cpu_state(CPUARMState *env, target_ulong *pc, target_ulong *cs_base, uint32_t *pflags) { @@ -11519,9 +11533,7 @@ void cpu_get_tb_cpu_state(CPUARMState *env, target_= ulong *pc, uint32_t pstate_for_ss; =20 *cs_base =3D 0; -#ifdef CONFIG_DEBUG_TCG - assert(flags =3D=3D rebuild_hflags_internal(env)); -#endif + assert_hflags_rebuild_correctly(env); =20 if (FIELD_EX32(flags, TBFLAG_ANY, AARCH64_STATE)) { *pc =3D env->pc; --=20 2.20.1 From nobody Sat Apr 27 18:38:45 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1576852638; cv=none; d=zohomail.com; s=zohoarc; b=gRsoaXBncXqcwMvtGO3l4si4QTTji1AWjD3Kv0oPuBUBGUcG2oXIEfCZ8XbfwSPO+AU9QAWCPm49Mbeclc+mnqabaKdCbzIDjz5lm2w29Uj7Pm4QlWV2Rpicby0ZcSGU5BXYCpt8NV1lmbaf+ruLOSlM3SPFDZXTW0k6s6gD9JU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1576852638; h=Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=dTAik/55XqF6jZEApcTun6adu0lplKSvcNyPRiElySM=; b=R4RafTx4ZgmRfG2tTVmjQDvuP554+vh9WEhfhU7QxBeQY3qzOqQFeZbbbe+x0caz0Y0/Yt8sAiUmpBhjWuAwmpNZ6Y6N+DwarjaiAprbw2gWwxnUaUNDdin+jUSBYrcf2OTY35gur/ZREpeyx9qwuwNnCwqt1MconxU7TXxo08A= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1576852638315287.18499268660196; Fri, 20 Dec 2019 06:37:18 -0800 (PST) Received: from localhost ([::1]:57306 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iiJP3-0003Bz-33 for importer@patchew.org; Fri, 20 Dec 2019 09:37:17 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:41899) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iiJFB-00050d-UL for qemu-devel@nongnu.org; Fri, 20 Dec 2019 09:27:06 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iiJFA-0007hU-IE for qemu-devel@nongnu.org; Fri, 20 Dec 2019 09:27:05 -0500 Received: from mail-wr1-x444.google.com ([2a00:1450:4864:20::444]:41232) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iiJFA-0007dk-9u for qemu-devel@nongnu.org; Fri, 20 Dec 2019 09:27:04 -0500 Received: by mail-wr1-x444.google.com with SMTP id c9so9605286wrw.8 for ; Fri, 20 Dec 2019 06:27:04 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id t5sm9741814wrr.35.2019.12.20.06.27.01 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Dec 2019 06:27:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=dTAik/55XqF6jZEApcTun6adu0lplKSvcNyPRiElySM=; b=jbBrSTaS/8Jnb7aAX3hzxvXCKcQoCm0mmQ9lhRbfudQxTvEdkSTbxtMgQo2peeoYsB DBut85jeI7qeFJOeJaHlDEQX6kuWDW3ijetIxwbIulDbmj+pQ1sUw048Ma/CDfWt0ioQ meMV6yabMAZ+vNpeXWHybprgOkdkJjE8PWT9zyJ0DBa/kwPXJwxt2Hs2JLQRMT3sU1jF 3AmBMawNSES4r28OmyFvaXdRcmvA91M2pYFpI8IONAXzPgtSVUW41dDoP1pl9+0KofXh jee94JCEhhs0+nZVeUtjyMPu3KkOU6fVRll3DM+Q8C22+z6JM9616N0Ar3assPWYFw5h rfdA== 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=dTAik/55XqF6jZEApcTun6adu0lplKSvcNyPRiElySM=; b=UEk/jZUHKGgZr5OvnZHLgUnF30wUvL730d18H5G7MYmXxB//26NVQq5Aalid4lQwhR +k32ePbWAvBhob1VoZbIYz7izx+VT54FFYQc5ZS+DI2b7KsJ9ObXyDlEGPCIr+3jzs0l SGvJ+AUFw5FoHsLv8hCcVhnRchMbtQ0QFjYoDqVyevGpMJtqsGn0o2kEDbM5C3F1MilN f/WytB9SIxpMmLSFN95ADij9sq7GteMzzTVhg5iJAibLUJa3B0nQlKL5D4Ja94FHTXt9 /iabpOBvYW+ohPUYHQDw4L9jElJne0hRtGjFCXsJo9x1rF2jCsWx6ybalAC89usuvll7 4NuQ== X-Gm-Message-State: APjAAAXvstJTS7BmP9D+XVqPfF171bOgwZsJAU/ubPcbNlAeQr91ZpNI rSyPaudtvSAxcfLUXul1yoCb7nasxM7SuA== X-Google-Smtp-Source: APXvYqy/AasgQHzF4RgNYOlpa4nCvkQsnrgtuONRyDjR09EuFg1SPJWScsjrUxGnZUTF6XEBqBH8fg== X-Received: by 2002:a5d:5267:: with SMTP id l7mr16799576wrc.84.1576852022990; Fri, 20 Dec 2019 06:27:02 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 12/12] arm/arm-powerctl: rebuild hflags after setting CP15 bits in arm_set_cpu_on() Date: Fri, 20 Dec 2019 14:26:44 +0000 Message-Id: <20191220142644.31076-13-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191220142644.31076-1-peter.maydell@linaro.org> References: <20191220142644.31076-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) Content-Type: text/plain; charset="utf-8" From: Niek Linnenbank After setting CP15 bits in arm_set_cpu_on() the cached hflags must be rebuild to reflect the changed processor state. Without rebuilding, the cached hflags would be inconsistent until the next call to arm_rebuild_hflags(). When QEMU is compiled with debugging enabled (--enable-debug), this problem is captured shortly after the first call to arm_set_cpu_on() for CPUs running in ARM 32-bit non-secure mode: qemu-system-arm: target/arm/helper.c:11359: cpu_get_tb_cpu_state: Assertion `flags =3D=3D rebuild_hflags_internal(env)' failed. Aborted (core dumped) Fixes: 0c7f8c43daf65 Cc: qemu-stable@nongnu.org Signed-off-by: Niek Linnenbank Reviewed-by: Richard Henderson Signed-off-by: Peter Maydell --- target/arm/arm-powerctl.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/target/arm/arm-powerctl.c b/target/arm/arm-powerctl.c index b064513d44a..b75f813b403 100644 --- a/target/arm/arm-powerctl.c +++ b/target/arm/arm-powerctl.c @@ -127,6 +127,9 @@ static void arm_set_cpu_on_async_work(CPUState *target_= cpu_state, target_cpu->env.regs[0] =3D info->context_id; } =20 + /* CP15 update requires rebuilding hflags */ + arm_rebuild_hflags(&target_cpu->env); + /* Start the new CPU at the requested address */ cpu_set_pc(target_cpu_state, info->entry); =20 --=20 2.20.1