From patchwork Wed Dec 18 18:15:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 851745 Delivered-To: patch@linaro.org Received: by 2002:a5d:4888:0:b0:385:e875:8a9e with SMTP id g8csp1075392wrq; Wed, 18 Dec 2024 10:17:00 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCUW12Mr4XGr8j3kVBGVzGqm+l9zngOeRBfKvZNnnT6Wsw50ASMg7OtAdmpPX+/5y0W23qS/GQ==@linaro.org X-Google-Smtp-Source: AGHT+IGwFQpiGySIxZwTe+shxtP1xgwMvcG/zIgrDiBSIbszp5ID/74tZc3Y3Fwam3KFDvRybk8s X-Received: by 2002:a05:620a:2688:b0:7b6:cb1c:aa22 with SMTP id af79cd13be357-7b8636e870dmr680695785a.1.1734545820505; Wed, 18 Dec 2024 10:17:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1734545820; cv=none; d=google.com; s=arc-20240605; b=imaYarpw0fLdhcIAulkEz2A/e8xj+vZ7bwn4wjZrCu+h9CsUPlr3mn5/wLn6Cc11vw rCIcS+DDTIEBbGuC/5DmsqF3UwcqHhVC1Ui5I6r6sYKWciYNIDRwSMFYLuPDen+gMYnI FdF78Q8xzGkHNsNn13irZW5iCZ2IxLhgtL6g8QZiMW0guqNrG8SksMYtpn8451mGmuei lrNZ1X3WQTikoEGG4H2ORH2ZzCyv9ZTB2rjRzgBnv3f66Zd6qD8e14te9kvhMSKRoRTH CxZFoblkJFSlMkJ/L+477T+ujHc5LQFrSoEJ7p0D2agmj6coGnCY9dcYgHd5hegRVJKY JOLA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; 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:cc:to :from:dkim-signature; bh=1kN/ZYXoIAzuNuSPL620rsLxZYj3p6quBDyJTtx4PN0=; fh=n+7/i9AUPusiia8VmzoiBlwSlyFeXwpWgjR6Od+Rvhk=; b=G5P0moWV6VuqZ15SG+jHeDQ6ccWmbXXwYLcUldZTdqSzNGFlSjo7gIm33DIskIymGY ABLVWIAnYLpMy52n19HyEwOGJ2qf6joJkV131MxsRstkvBzGqDFUQX4nUKdCFhAc+6K+ ZJjcCNJ2dESj+13ic8Vuv6bBmTOmmupsScN50VscIniU8XSDqVykoozqgOaoTUYDjeYt fbrqiTTo8BlvhprNZkqNVQGJhncbnOnbHjRwcNK0xUu+hbcyneazPQTLw/8D+hAZ8f9V 7HUnaRU5VdZEmhce83QZ0paoX/rz0Z1bDl0HzIE15ulhiUM0vWdCGpUzSbLePMQzbn7V IU2w==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=qR3VP4Vt; 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; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id af79cd13be357-7b7047c4e34si1326043785a.86.2024.12.18.10.17.00 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 18 Dec 2024 10:17:00 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=qR3VP4Vt; 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; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tNyaq-0001KZ-VG; Wed, 18 Dec 2024 13:16:28 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tNya2-0001BD-Js for qemu-devel@nongnu.org; Wed, 18 Dec 2024 13:15:30 -0500 Received: from mail-ed1-x535.google.com ([2a00:1450:4864:20::535]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tNyZy-0007Vc-Bl for qemu-devel@nongnu.org; Wed, 18 Dec 2024 13:15:28 -0500 Received: by mail-ed1-x535.google.com with SMTP id 4fb4d7f45d1cf-5d0ac27b412so9375904a12.1 for ; Wed, 18 Dec 2024 10:15:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1734545715; x=1735150515; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=1kN/ZYXoIAzuNuSPL620rsLxZYj3p6quBDyJTtx4PN0=; b=qR3VP4VtC82gaa/mOQQ5md1aRaSB3uy8pb6jAUlo59qovSG/6rTcudADLLUmg2X3lm k0UvemaAg6upaw6UzB+y23qdWgn9PYqJPyrqF8o6lRnB0nEN3GmYNraat+ZoNPL2EGvW BfvrwZzXlq3yGztVPl65AF5YkRlZkPESAhq2+zsXd/7xmw7oZpuk2v4+ukI65VMbzs6o rzMpQkUjkbkwIONABlsQsfL9/4nVyuphu/JuLirHEP1ciAJbzB/ru97qAnsyITvAfxGa OU8aRUDEvUTm1XajnOWXHo7BFL8nxPiRRiyHXvlCqLl6KwGtdhH4xCO0exams0Nxkwk0 xbxw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734545715; x=1735150515; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=1kN/ZYXoIAzuNuSPL620rsLxZYj3p6quBDyJTtx4PN0=; b=LhmqSgRslf4pNzILmlnM+gvzMtGu7fyAMeTmGjGPtXJHIHAJuK1yPSz8DmhhvffIsr jfFhK9R2Bgzt65+NyCbCfrzvDP9vk4/lx2KoktgdqPN1EFIxn0l3MTnnXXPbWWdrOMxb xzxcjyitpVrWwEt8iywY5Csj35IOQ/wjzfSzANSo2b6bJ5OmhA8qQOEwRsArn9NSaztj 9vERMTiCu4rzT/Zp6CnDA6MsxLI4QNubIM56V5gEu54nzPQX7jceqJcHgk3ChEMXiqOl Q1SwuwJFvU/Yu2pZPp3AeyHZKDpfNWClANKBAEtxvODaT1KNgqaz2q2fw8e/YW0WAsXW JHmA== X-Gm-Message-State: AOJu0YxmvR9TQF+z6M0gqIPWtjc19PxdSdhexAcpQJENHzCEsUKHpZTV 3KXcINHDyktkSdmrNFqLQrxwQNdb61rnXnjmojPvDIit/YutbloZCYnE/OqdIxk= X-Gm-Gg: ASbGncsqp2UJdA8PvUlmQmOl2ctUIbDE51ob8jxXT+RrHU9/7Dw1/w4lMIZNDMGJo6b wMpfePU18A9XHlrGMvmOD/E+XuP9ospGcOc2+iUyg9DxLE5zLsqF+aS483SAPP5KbrLW78VVeVP 9tHVuWG5WtqfCIwvELgmZk9cshnXWMCoqrD1f2DWmRhbr61upjpKGhSbif1rEzAIYxDy1BR+Lp0 6yvykqAVEXrQaPSPYcwaKCRPo7LonJx/1UT13vsHYiWBxixC8Ty4gQ= X-Received: by 2002:a05:6402:43c4:b0:5d0:b040:4616 with SMTP id 4fb4d7f45d1cf-5d7ee41e7fdmr3678720a12.28.1734545715136; Wed, 18 Dec 2024 10:15:15 -0800 (PST) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5d652ae10a7sm5564454a12.38.2024.12.18.10.15.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Dec 2024 10:15:13 -0800 (PST) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 9FF175FB2E; Wed, 18 Dec 2024 18:15:11 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Leif Lindholm , Leif Lindholm , Marcin Juszkiewicz , Peter Maydell , Radoslaw Biernacki , qemu-arm@nongnu.org, =?utf-8?q?Alex_?= =?utf-8?q?Benn=C3=A9e?= , qemu-stable@nongnu.org Subject: [PATCH v2 2/5] target/arm: ensure cntvoff_el2 also used for EL2 virt timer Date: Wed, 18 Dec 2024 18:15:08 +0000 Message-Id: <20241218181511.3575613-3-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20241218181511.3575613-1-alex.bennee@linaro.org> References: <20241218181511.3575613-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::535; envelope-from=alex.bennee@linaro.org; helo=mail-ed1-x535.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 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-bounces+patch=linaro.org@nongnu.org We were missing this case and will shortly be adding another. Re-arrange the code and use a switch statement to group the virtual timers. Signed-off-by: Alex Bennée Cc: qemu-stable@nongnu.org --- target/arm/helper.c | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/target/arm/helper.c b/target/arm/helper.c index 910ae62c47..5a1b416e18 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -2465,16 +2465,27 @@ static void gt_recalc_timer(ARMCPU *cpu, int timeridx) ARMGenericTimer *gt = &cpu->env.cp15.c14_timer[timeridx]; if (gt->ctl & 1) { + uint64_t count = gt_get_countervalue(&cpu->env); + uint64_t offset; + uint64_t nexttick; + int istatus; + /* * Timer enabled: calculate and set current ISTATUS, irq, and * reset timer to when ISTATUS next has to change */ - uint64_t offset = timeridx == GTIMER_VIRT ? - cpu->env.cp15.cntvoff_el2 : gt_phys_raw_cnt_offset(&cpu->env); - uint64_t count = gt_get_countervalue(&cpu->env); + switch (timeridx) { + case GTIMER_VIRT: + case GTIMER_HYPVIRT: + offset = cpu->env.cp15.cntvoff_el2; + break; + default: + offset =gt_phys_raw_cnt_offset(&cpu->env); + break; + } + /* Note that this must be unsigned 64 bit arithmetic: */ - int istatus = count - offset >= gt->cval; - uint64_t nexttick; + istatus = count - offset >= gt->cval; gt->ctl = deposit32(gt->ctl, 2, 1, istatus);