From patchwork Fri Dec 6 16:02:37 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: 847833 Delivered-To: patch@linaro.org Received: by 2002:a5d:50c2:0:b0:385:e875:8a9e with SMTP id f2csp856969wrt; Fri, 6 Dec 2024 08:03:55 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCUsz+UXjRNHWqQnQDH2wX57n3ZA52VI+WxaSsdnm1wFEYY39Hk1PTs1aLMCkbgGSQsrqHG0zA==@linaro.org X-Google-Smtp-Source: AGHT+IEyKwQKKlHigiBzehhwXgLPxn1s5zw3kCTLB149ap2gZ8l5Cx4KDUV4seDtlQRYeFoglm+5 X-Received: by 2002:a05:6102:5127:b0:4af:c31d:b4e8 with SMTP id ada2fe7eead31-4afcaa8a77dmr4208254137.14.1733501035323; Fri, 06 Dec 2024 08:03:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1733501035; cv=none; d=google.com; s=arc-20240605; b=e9pk+A4CDAaJp7n4+cIESmAfGaobUO4R0kyz8fnyYNrRGapt6mdnXBSUwYfDEW1SZO SjoLTCHiMtoLL6Hfj9AdRXgyCQ64cHBa18E07MQQNWcQWDB8GlGUPbuednzKqvn/Szub 9H8B23qgV7Xw1e7DFT+NMrQVRTjRxgTsvflyAV+ZBH+oQgv79y9hplc3ivUARFgnClJ0 H35Hr1gUDTeFgclCzRmJr5MSxwAvaStpHZj/yny834eABvkUiu2OZdQXiUWlrhUMs00P HSuqzVIq387RH0igbMWt/Z6yL31dDINhrtj3Ln+fNdgNkA4u+Bv7lp9s/D/J1V5HW8XM jTlg== 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=nQKmXaN26XakuY5wULDcEXM0cF+Wz7SAC/9+7yYIy8o=; fh=P54XFR90eQD18n4tjJKAnsq1e9aOj0o7m5YYD9Kfr3Q=; b=RMqT8xdhwphlCJ0Lc+6Qq3qXBPBi3FmdWENvzFoEJh2/ImCcrs4tQUM0CTCmdOay3/ aDt3P0cwoVotVNyzeCwHgcNyKxckcyKZYncAIczoIv25/h8LC/nIkaxnKN3vf1SS/vsU kv9WQPOjcWyX3pYAUb1f0R3sGdzKJb3FLD0MXALrqK2tEYW14TwdQo0kpyUDW2HkntOu 8ROazVcILObSWpmHh/vEeOX+bw1GAaOse3FTMk9HbNekQO17KjG57fiDqrQo2dWBptAz 9diKKRtBi8SGmiN9Tt2Z0t9y4Wagqq2kAqIC2wW+nWIyXzZt7n8Dx/ufucWbD5GyCTP3 bi3Q==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=vpuj1E4l; 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 ada2fe7eead31-4afd512eae5si284584137.165.2024.12.06.08.03.55 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 06 Dec 2024 08:03:55 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=vpuj1E4l; 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 1tJan9-0007kO-OU; Fri, 06 Dec 2024 11:02:56 -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 1tJan4-0007gU-DB for qemu-devel@nongnu.org; Fri, 06 Dec 2024 11:02:51 -0500 Received: from mail-wr1-x430.google.com ([2a00:1450:4864:20::430]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tJan2-0006WS-U2 for qemu-devel@nongnu.org; Fri, 06 Dec 2024 11:02:50 -0500 Received: by mail-wr1-x430.google.com with SMTP id ffacd0b85a97d-3862ca8e0bbso660043f8f.0 for ; Fri, 06 Dec 2024 08:02:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1733500967; x=1734105767; 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=nQKmXaN26XakuY5wULDcEXM0cF+Wz7SAC/9+7yYIy8o=; b=vpuj1E4lLRPpCcRLCBTkfy/9rRaNVJu922Q8vCgHOiokpRNcNLLlhmI6d/CzVT7VJb NOtYPbhYdCqO/DbJgz5rYfDxxW6slD8nVPmLRQum91bv1NlmbUU3bbgW59eYOOXMlebJ X/uBi30eavZHatED+eYVIoSnVjvjJAD4j4yYn76pvHDA+WyVOZV7ZR4FMdBePHHhG1EJ rnect46CAyHOerocw3JR6NJcGw8HHqkgitxqvZUUCdloIyxQMx38dU13zdTjxEEwFc0I jHJdoPjKJZJsCPR3EF8fxS01PjUtyelP5mDq30BaqdUualBxXjTY7OAKMX1xA9y5egyt yjCw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733500967; x=1734105767; 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=nQKmXaN26XakuY5wULDcEXM0cF+Wz7SAC/9+7yYIy8o=; b=DU8cgM11y1MuXquuUvRposWIP+MCFmcT7VN2iVz4u5wAonktOVPaE+pngUqmd8oW+C PDTvoYAauvEpxPn6paQiOL7uvwyScuDqISYDN5ULrWGO07kKN9oOD9iaFcrD4FioYR+E LTwfafihJ9PDXlKOgiItJWC8JyP4v3BExaIL8DuTPQc0PEw0wJuM9hMYOnpNw5aYNsQH afZQFlj5jldYSAPB4UCcFky2wvvcyfI7BQ/f/OAYVeAYf58Phh+GSqBoVrk+/OMUqd9j fFJyVG4fTNpD3YfMNj9jI8jHDjTPd3sNPUN+o5SxOAQGMgDS4u/GfKxvnSD2ml2Wc8iV d00A== X-Gm-Message-State: AOJu0YzMt6509Q2HScRl4q9Vw7fYPJ31W95D03kh3j4mT2FaV5OgyRoY dvzIUYTvgbfqzC7F9X0WvReg4ViYaxtUfjPCtFssTuYHJ0Ir+SFjh+fqtEnA+aM= X-Gm-Gg: ASbGncuJl21Zl39rsWyp7tWr4JUY7R+893Bs+1O2dmDL4t/E46AQj1tT5AzLZzsbrYi QsG/h9lnpNDRWx5P5dFqAwIPSUDVCXhfyfHOGhCvsIA2Jk9uVOG3TwoQ2ZnzE7d7flNT+KEyj4M XJ+Vuew4/KvX3BIiIK/R7w1y42gkFqo3Y5tn5YenmPSCKpIKjVI/bFUbt+Nf/R9F5C+fRwPDuxZ M0vHInPZ/ko4F/VUjaqKcnfUS537eWhO1WnWqVu1N6CvTml X-Received: by 2002:a05:6000:3c3:b0:385:fb34:d5a0 with SMTP id ffacd0b85a97d-3862b36d067mr3175114f8f.29.1733500961848; Fri, 06 Dec 2024 08:02:41 -0800 (PST) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3861fd46cc8sm4791799f8f.59.2024.12.06.08.02.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Dec 2024 08:02:41 -0800 (PST) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 75DB25F9EA; Fri, 6 Dec 2024 16:02:39 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Marcin Juszkiewicz , Leif Lindholm , Peter Maydell , Radoslaw Biernacki , =?utf-8?q?Alex_Benn=C3=A9e?= , qemu-stable@nongnu.org Subject: [PATCH 1/3] target/arm: document the architectural names of our GTIMERs Date: Fri, 6 Dec 2024 16:02:37 +0000 Message-Id: <20241206160239.3229094-2-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20241206160239.3229094-1-alex.bennee@linaro.org> References: <20241206160239.3229094-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::430; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x430.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 As we are about to add more physical and virtual timers lets make it clear what each timer does. Signed-off-by: Alex Bennée Cc: qemu-stable@nongnu.org --- target/arm/gtimer.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/target/arm/gtimer.h b/target/arm/gtimer.h index b992941bef..de016e6da3 100644 --- a/target/arm/gtimer.h +++ b/target/arm/gtimer.h @@ -10,11 +10,11 @@ #define TARGET_ARM_GTIMER_H enum { - GTIMER_PHYS = 0, - GTIMER_VIRT = 1, - GTIMER_HYP = 2, - GTIMER_SEC = 3, - GTIMER_HYPVIRT = 4, + GTIMER_PHYS = 0, /* EL1 physical timer */ + GTIMER_VIRT = 1, /* EL1 virtual timer */ + GTIMER_HYP = 2, /* EL2 physical timer */ + GTIMER_SEC = 3, /* EL3 physical timer */ + GTIMER_HYPVIRT = 4, /* EL2 virtual timer */ #define NUM_GTIMERS 5 }; From patchwork Fri Dec 6 16:02:38 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: 847834 Delivered-To: patch@linaro.org Received: by 2002:a5d:50c2:0:b0:385:e875:8a9e with SMTP id f2csp857354wrt; Fri, 6 Dec 2024 08:04:21 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCWLsZNQTHrlDtxhtkKPSVwNzdSnEUbbpO9nTEPuTIJqhJHeq38aGNY/VyDBHCrqt2FvoqwQ9A==@linaro.org X-Google-Smtp-Source: AGHT+IGV9OmPaPDXDLt2+KkgJiPpQTBBVEwb+eHolwCsh1lefwUdn5gKxtbmSLSOOiH/c4i49/dz X-Received: by 2002:a05:6122:2a02:b0:515:d032:796b with SMTP id 71dfb90a1353d-515fcaefe1dmr4219332e0c.11.1733501061541; Fri, 06 Dec 2024 08:04:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1733501061; cv=none; d=google.com; s=arc-20240605; b=I4WSqhH+e+L+qEoYQoz7hJkHqbv9HBugEJ5sQtW/zwlYNFXssOoYRd8DNLN5k2uL58 M7UvTt9M/nOGZ7C0Yt2lgevqY6x2nivs6RJNOCnYxSl1B1/yb8xrUsATw3U5Gpmpt3t5 brWwWg6JmEBwcbbFMjSblXrRhtvTeouJCzxQCIonl9Q8uysmGZcV76Tpj9iB7AIgbTFc uUY/Opf8D9ab3hu0QKBZJXz48wUBACbrDdQPasjM1E1WheC7qeCVBYiqY1nF2xIgk/I4 LcqR0DRctMuuT0mHeaQRaMio8XsOXnn/Umee8HtP0bovkkPzMLQ8jViP5/ypFPfGiMEL Irdw== 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=DpWlHsnEATKQd9doFDeJag8Oztk1AQr7X7UO5Wk5+f0=; fh=P54XFR90eQD18n4tjJKAnsq1e9aOj0o7m5YYD9Kfr3Q=; b=iXcD7teFrRS7FqcLHysPTBVHwjnlmxIvIr12FBCzkKL1Lcqga4X+uvaMLtQ/DDZAoI TwYEFY12KRrLm78vK4wDqT/O/xWW7r2/9wSiISdIG62rKtnzwB3aOF5SvDXf4mHGfuZi +VchdZ+6VmM/NvWGunAE4GI+GOs5UiA5O1DJcJQh4arvFxPzKxgq/4xkpZ2ihhN+fJ/g haWWY2evrhwuLKM9+4QnZBMFwzNDYVW7PG0qFZpEvMvemQ63EnIfGMsEiESZbm6k9qoK nmCifffNIQHgzLmcodFPn5DbofIk+h4t2yaNnXVSZDBSrsbpN50ERt0DzVvD0USk1hCt JEbg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=o8xRMdq6; 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 71dfb90a1353d-515eae15f72si1255918e0c.22.2024.12.06.08.04.21 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 06 Dec 2024 08:04:21 -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=o8xRMdq6; 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 1tJan8-0007ie-B5; Fri, 06 Dec 2024 11:02:54 -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 1tJan3-0007fz-0a for qemu-devel@nongnu.org; Fri, 06 Dec 2024 11:02:49 -0500 Received: from mail-wr1-x434.google.com ([2a00:1450:4864:20::434]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tJamz-0006V5-Og for qemu-devel@nongnu.org; Fri, 06 Dec 2024 11:02:48 -0500 Received: by mail-wr1-x434.google.com with SMTP id ffacd0b85a97d-382610c7116so1269299f8f.0 for ; Fri, 06 Dec 2024 08:02:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1733500963; x=1734105763; 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=DpWlHsnEATKQd9doFDeJag8Oztk1AQr7X7UO5Wk5+f0=; b=o8xRMdq63cHXP4SFy2/tGuweni+SH/3QtFzJaXubUQ3D8SnycWxfUSBv9TIXI8ztjA zL9RZL4zl8XkzMvTEqtQmhY5Gxw6+eLIuXXmzV/O1WjzWBzKB3TKSu+zyQNXtQEjt6V/ jwKGa/gmWMWH/Bh4NNbllOCW8JDl1hxZBzKiY2GEW677PEDv+OC6tfwkzRykTPTmm5GC J6l/hGysP+7ChMHzpzR6on83Ing24LTWIpzBxnN6f++UPlVxyAvRsWRMKu3N5HTX4C0e a+PEdj1mEyhoMA6G/WfSNp2WOHRHXYgR2jcxR2epbH8/XyuRKnmcl54WpsI1CVhIwjyY Finw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733500963; x=1734105763; 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=DpWlHsnEATKQd9doFDeJag8Oztk1AQr7X7UO5Wk5+f0=; b=MusCMzfLDVbrLMGgfmmfB1a1IMIxIJdX0KRgCjeGyofbfn3amJbYeOTEJm07dA3Ado zlJw2ox73/bVgkkEA3flhgsJlh+DMc+4MaB1H44dZctPgcfLyPh1Slya+/rbTgPNe3vO VJqiAmCQmUYVv2P+IjJvym58PA0YLXeW38cz39kYxBnHRebNzIHx1hWG98YSfzFuKOPR 1vaOiPAywajtMG5VyL0KvrX4N2wORqQgNPanvfO6VSI80YdpbDK0G16lCqXJcFfewazX ilF5F8feVZ+ekXIppE9b3OEdd3FDwKHVflRXctdMWEwMkBH3hjSTpMLOG7J7Sica5f7y Mgcg== X-Gm-Message-State: AOJu0YwZgxLnkYxQverGRBBnCewl4Ew4o1CY06wICjp2FCji6+qP3d1A DHQasi4DALyHWKIQP2JCXQ+y1OjCLZvclMHyxpfjiF28H1yjdO0CipFckMH0VFY= X-Gm-Gg: ASbGnctZo4GBIF74uXIc0MmzqS0YmU1wqYKgBKn3Ud+WgSAVD5YyfFRSqNA5Q/7/Bzo HJ2PzAX+IIbqct/G+ok8KqUy/XYnD0+FWVmTDDQ1eCmupunOfzy/CcCgaGZTtZTE823l1nyMhgv 2EaEyLaVKUgzPGvpX2Hum98GKG0AZ3DT/Ral81ypHnWn59WxbyvDobg/9/zmt5BWeq158yC0KRX H+K3ReJ5XnPBXmZnnU2Z7eYkRhWiA7gqT031ynQlA2JOn5e X-Received: by 2002:a05:6000:470d:b0:385:f38e:c0d3 with SMTP id ffacd0b85a97d-3862b3f0cabmr2461963f8f.58.1733500962931; Fri, 06 Dec 2024 08:02:42 -0800 (PST) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-434da1134b9sm59273725e9.33.2024.12.06.08.02.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Dec 2024 08:02:41 -0800 (PST) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 8C3695F9FA; Fri, 6 Dec 2024 16:02:39 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Marcin Juszkiewicz , Leif Lindholm , Peter Maydell , Radoslaw Biernacki , =?utf-8?q?Alex_Benn=C3=A9e?= , qemu-stable@nongnu.org Subject: [PATCH 2/3] target/arm: ensure cntvoff_el2 also used for EL2 virt timer Date: Fri, 6 Dec 2024 16:02:38 +0000 Message-Id: <20241206160239.3229094-3-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20241206160239.3229094-1-alex.bennee@linaro.org> References: <20241206160239.3229094-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::434; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x434.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=unavailable 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 f38eb054c0..cd147b717a 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -2732,16 +2732,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); From patchwork Fri Dec 6 16:02:39 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: 847836 Delivered-To: patch@linaro.org Received: by 2002:a5d:50c2:0:b0:385:e875:8a9e with SMTP id f2csp857367wrt; Fri, 6 Dec 2024 08:04:22 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCXHCAFzPYxp9TT+Hp+aW881tzEhsJ57wrVWP3njiykjKWoFZNJjTpeaU8DlFgwY5u+QkAiPmg==@linaro.org X-Google-Smtp-Source: AGHT+IHyDxHc8JIVeFyNuDPZGVmXPDDCQJNe7ea81vFG3BQcCdPKeK+v4VLoIw+g4QTva0MulPS2 X-Received: by 2002:a05:6102:4408:b0:4af:c435:58a2 with SMTP id ada2fe7eead31-4afcab253c4mr4964363137.23.1733501062305; Fri, 06 Dec 2024 08:04:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1733501062; cv=none; d=google.com; s=arc-20240605; b=QyiR5fmDCqkn88H+TWrkkGfkPH0C2XuL8nm4ZHUn0eCqcFVV6wEoJyfEHPEmZyqArP nCs09+lUDhiTuKdCY6zEoYORwXPwl8bqS1uFFZevMqz6GK2aQCM0LDpmnfzyZT/RkFPi JBM6OQIo5Xxj3+76obDX8VVpWHp4sFkmb1aAPzP7c7J23jMizGr7zIwYseZGMDY1JOdx 837pD31O4cSM62VxjfEJkCJ+yQLe70H1qbdUnl/dEEY8zrF/D+pYBebfhTj/BEguoffj aGVJVqAwZuFqdBt+tQFf2F0itQjfLtvufMsahM+8ciVAxNsgJVcwz6XQDwn9VzFYeO4q GQCQ== 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=lSUUCyFArbxy+0GSSuSuEHiOsnV3phawKrAnzeeaAVQ=; fh=9oeQMC406LlQBQl3+THM4G0JwOP9TtP2ZSDKCsT3npc=; b=PJtR1URmdqKtVOT4S6Yu3F+rpHXGvahoHQ9O6+azPFLMQdncGEf42dAMPx43YCwZ5q kWheAB2MxVh5ErdcPIGDhRBUptue8wR5GWSs8wupB5e84m/bZkAVpKNheZ/UzlHnhNi2 N4gi0dKhu+pJwX8WTXQZP4DCwCnv7qnZbuwXD4LjGMZ7EqurZdP0vH4eebyrn6WRhOyh V3Sisfj5KXRbWvndM+rnzfza/wqCCLWAjKny99Evj3D9YXLGiVYuqzQxqQAMNdGxNOzN cBBOyN7teSFwZvqgkupgc6wO0r2lVN6sS1J+sL8cq6dCFRaipGQdNuuz3pPLGZgWnQG4 Z/VA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=SYIjXB8O; 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 ada2fe7eead31-4afbc691e61si1244357137.362.2024.12.06.08.04.22 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 06 Dec 2024 08:04:22 -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=SYIjXB8O; 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 1tJan8-0007iM-BZ; Fri, 06 Dec 2024 11:02:54 -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 1tJan2-0007fu-9R for qemu-devel@nongnu.org; Fri, 06 Dec 2024 11:02:49 -0500 Received: from mail-wm1-x329.google.com ([2a00:1450:4864:20::329]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tJamx-0006Uj-V1 for qemu-devel@nongnu.org; Fri, 06 Dec 2024 11:02:47 -0500 Received: by mail-wm1-x329.google.com with SMTP id 5b1f17b1804b1-434a0fd9778so22086345e9.0 for ; Fri, 06 Dec 2024 08:02:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1733500961; x=1734105761; 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=lSUUCyFArbxy+0GSSuSuEHiOsnV3phawKrAnzeeaAVQ=; b=SYIjXB8OZa//AgRVRBubs0gtK6U9W73UEFwJm0SCbEdou080SJ6c4HqO0a8B9mssql brz/Jg8PbJio6DlN0bDkyfOZH6gSxdfpk9yIecaSfwUGf4Ad1lZpzoiMIjAk7vJGQ5cE Ypc+Kwn9p1WhnVUkJRwIUMWQlGys7v0uGjt+HEddEDQL5Q2ppOxQ+OtCIK85ZY1rIxAc a0MAJJZQsFdbKWF2rCoy5wr1xWTRTvJYdoKswXMBSVSPElZJ0Pu/J3dTqWr2JLkggmrI cQZw+66GgVb2C6ulKpoOD79qMWrGFE1R01zYHnWssqh/h44LtEFg9OEBcpOwaRDwMsxK 6Ijw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733500961; x=1734105761; 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=lSUUCyFArbxy+0GSSuSuEHiOsnV3phawKrAnzeeaAVQ=; b=AtPNEXgNaTRr+KBnIoQEOn7NlYDcTcGvpSlgCXSUeI1EpLJ4ESgsKUZBvUWsvc4ZCr AfzX6y1WVwpS8F9FagKvYyZFmex4LNfMlMYAwhgMZQeHdKy8kMt9zAEaoV3luPCe9mRw e3GfxrBohCPPdKfJrN3CZjO50FLS+0SFCKypF0gx/eNBu6OMGsIwJpnCkyJjOQ5e/lSH 2SC4OUkbedfKcFH5AxRJvAvqaxhz3U2/UnMus2timo7RMVBvFKH2tblEKX/DQzZkANDA TaFhj4oT3Hi2Z+gG66946WlwIaQVrykUbeNAfNo+IyKrbVnyGzjZPoESeo3r7iotoHOJ hE0Q== X-Gm-Message-State: AOJu0YxZpPtX02S+TH1PqnXQuBlpDaRK8jypm5orO+yN2ELcdqqUFKA/ WlbGzURC4rusO8NfO2Rrjv0PdnHmaeKYypE/e1iIB/vQPTOmYRVaDACUXpUKX/I= X-Gm-Gg: ASbGncuahLepbtyhyN6sWnUCkVJ/V2fPpv/1DbxWWbEESis2tLvQYVpD473OqCgkfi7 iN7KKpHL8q5QV6BhrCm4FCrjc9be4g9IZ92ln1QBj6T/hyocY4Vvk1jPmIBepnFGp7TxTgdphvn oxNgndDtSeeMtDm0SU3jUdN1ndNlZtQt7v10duWAZk2rPxAHdOzJb9Cb0olNMYqaeASaUiKujjN LUjM89SMMTCYMobEa4Zu13AusHWEH4WPog3zO0hbf40UZTe X-Received: by 2002:a05:600c:1c8a:b0:434:a4a9:5d57 with SMTP id 5b1f17b1804b1-434ddeb8cf6mr29723485e9.19.1733500961331; Fri, 06 Dec 2024 08:02:41 -0800 (PST) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-434d526b14csm99454085e9.2.2024.12.06.08.02.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Dec 2024 08:02:40 -0800 (PST) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id A7D845F9FB; Fri, 6 Dec 2024 16:02:39 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Marcin Juszkiewicz , Leif Lindholm , Peter Maydell , Radoslaw Biernacki , =?utf-8?q?Alex_Benn=C3=A9e?= , qemu-stable@nongnu.org, Andrei Homescu , =?utf-8?q?Arv?= =?utf-8?q?e_Hj=C3=B8nnev=C3=A5g?= , =?utf-8?q?R=C3=A9mi_De?= =?utf-8?q?nis-Courmont?= Subject: [PATCH 3/3] target/arm: implement SEL2 physical and virtual timers Date: Fri, 6 Dec 2024 16:02:39 +0000 Message-Id: <20241206160239.3229094-4-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20241206160239.3229094-1-alex.bennee@linaro.org> References: <20241206160239.3229094-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::329; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x329.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=unavailable 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 When FEAT_SEL2 was implemented the SEL2 timers where missed. This shows up when building the latest Hafnium with SPMC_AT_EL=2. The actual implementation utilises the same logic as the rest of the timers so all we need to do is: - define the timers and their access functions - conditionally add the correct system registers - create a new accessfn as the rules are subtly different to the existing secure timer Fixes: e9152ee91c (target/arm: add ARMv8.4-SEL2 system registers) Signed-off-by: Alex Bennée Cc: qemu-stable@nongnu.org Cc: Andrei Homescu Cc: Arve Hjønnevåg Cc: Rémi Denis-Courmont --- v1 - add better comments to GTIMER descriptions - also define new timers for sbsa-ref - don't conditionally gate qemu_timer creation on the feature - take cntvoff_el2 int account for SEC_VEL2 in gt_recalc/g_tval_[read|write] --- include/hw/arm/bsa.h | 2 + target/arm/cpu.h | 2 + target/arm/gtimer.h | 4 +- hw/arm/sbsa-ref.c | 2 + hw/arm/virt.c | 2 + target/arm/cpu.c | 4 ++ target/arm/helper.c | 158 +++++++++++++++++++++++++++++++++++++++++++ 7 files changed, 173 insertions(+), 1 deletion(-) diff --git a/include/hw/arm/bsa.h b/include/hw/arm/bsa.h index 8eaab603c0..b4ecca1b1c 100644 --- a/include/hw/arm/bsa.h +++ b/include/hw/arm/bsa.h @@ -22,6 +22,8 @@ #define QEMU_ARM_BSA_H /* These are architectural INTID values */ +#define ARCH_TIMER_S_VIRT_EL2_IRQ 19 +#define ARCH_TIMER_S_EL2_IRQ 20 #define VIRTUAL_PMU_IRQ 23 #define ARCH_GIC_MAINT_IRQ 25 #define ARCH_TIMER_NS_EL2_IRQ 26 diff --git a/target/arm/cpu.h b/target/arm/cpu.h index d86e641280..10b5354d6f 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -1139,6 +1139,8 @@ void arm_gt_vtimer_cb(void *opaque); void arm_gt_htimer_cb(void *opaque); void arm_gt_stimer_cb(void *opaque); void arm_gt_hvtimer_cb(void *opaque); +void arm_gt_sel2timer_cb(void *opaque); +void arm_gt_sel2vtimer_cb(void *opaque); unsigned int gt_cntfrq_period_ns(ARMCPU *cpu); void gt_rme_post_el_change(ARMCPU *cpu, void *opaque); diff --git a/target/arm/gtimer.h b/target/arm/gtimer.h index de016e6da3..f8f7425a5f 100644 --- a/target/arm/gtimer.h +++ b/target/arm/gtimer.h @@ -15,7 +15,9 @@ enum { GTIMER_HYP = 2, /* EL2 physical timer */ GTIMER_SEC = 3, /* EL3 physical timer */ GTIMER_HYPVIRT = 4, /* EL2 virtual timer */ -#define NUM_GTIMERS 5 + GTIMER_SEC_PEL2 = 5, /* Secure EL2 physical timer */ + GTIMER_SEC_VEL2 = 6, /* Secure EL2 virtual timer */ +#define NUM_GTIMERS 7 }; #endif diff --git a/hw/arm/sbsa-ref.c b/hw/arm/sbsa-ref.c index e3195d5449..5dc36b3cee 100644 --- a/hw/arm/sbsa-ref.c +++ b/hw/arm/sbsa-ref.c @@ -484,6 +484,8 @@ static void create_gic(SBSAMachineState *sms, MemoryRegion *mem) [GTIMER_HYP] = ARCH_TIMER_NS_EL2_IRQ, [GTIMER_SEC] = ARCH_TIMER_S_EL1_IRQ, [GTIMER_HYPVIRT] = ARCH_TIMER_NS_EL2_VIRT_IRQ, + [GTIMER_SEC_PEL2] = ARCH_TIMER_S_EL2_IRQ, + [GTIMER_SEC_VEL2] = ARCH_TIMER_S_VIRT_EL2_IRQ, }; for (irq = 0; irq < ARRAY_SIZE(timer_irq); irq++) { diff --git a/hw/arm/virt.c b/hw/arm/virt.c index 1a381e9a2b..451d154459 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -873,6 +873,8 @@ static void create_gic(VirtMachineState *vms, MemoryRegion *mem) [GTIMER_HYP] = ARCH_TIMER_NS_EL2_IRQ, [GTIMER_SEC] = ARCH_TIMER_S_EL1_IRQ, [GTIMER_HYPVIRT] = ARCH_TIMER_NS_EL2_VIRT_IRQ, + [GTIMER_SEC_PEL2] = ARCH_TIMER_S_EL2_IRQ, + [GTIMER_SEC_VEL2] = ARCH_TIMER_S_VIRT_EL2_IRQ, }; for (unsigned irq = 0; irq < ARRAY_SIZE(timer_irq); irq++) { diff --git a/target/arm/cpu.c b/target/arm/cpu.c index 6938161b95..d15916c436 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -2078,6 +2078,10 @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp) arm_gt_stimer_cb, cpu); cpu->gt_timer[GTIMER_HYPVIRT] = timer_new(QEMU_CLOCK_VIRTUAL, scale, arm_gt_hvtimer_cb, cpu); + cpu->gt_timer[GTIMER_SEC_PEL2] = timer_new(QEMU_CLOCK_VIRTUAL, scale, + arm_gt_sel2timer_cb, cpu); + cpu->gt_timer[GTIMER_SEC_VEL2] = timer_new(QEMU_CLOCK_VIRTUAL, scale, + arm_gt_sel2vtimer_cb, cpu); } #endif diff --git a/target/arm/helper.c b/target/arm/helper.c index cd147b717a..f82503304e 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -2668,6 +2668,41 @@ static CPAccessResult gt_stimer_access(CPUARMState *env, } } +static CPAccessResult gt_sel2timer_access(CPUARMState *env, + const ARMCPRegInfo *ri, + bool isread) +{ + /* + * The AArch64 register view of the secure EL2 timers are mostly + * accessible from EL3 and EL2 although can also be trapped to EL2 + * from EL1 depending on nested virt config. + */ + switch (arm_current_el(env)) { + case 0: + return CP_ACCESS_TRAP; + case 1: + if (!arm_is_secure(env)) { + return CP_ACCESS_TRAP; + } else if (arm_hcr_el2_eff(env) & HCR_NV) { + return CP_ACCESS_TRAP_EL2; + } + return CP_ACCESS_TRAP; + case 2: + if (!arm_is_secure(env)) { + return CP_ACCESS_TRAP; + } + return CP_ACCESS_OK; + case 3: + if (env->cp15.scr_el3 & SCR_EEL2) { + return CP_ACCESS_OK; + } else { + return CP_ACCESS_TRAP; + } + default: + g_assert_not_reached(); + } +} + uint64_t gt_get_countervalue(CPUARMState *env) { ARMCPU *cpu = env_archcpu(env); @@ -2744,6 +2779,7 @@ static void gt_recalc_timer(ARMCPU *cpu, int timeridx) switch (timeridx) { case GTIMER_VIRT: case GTIMER_HYPVIRT: + case GTIMER_SEC_VEL2: offset = cpu->env.cp15.cntvoff_el2; break; default: @@ -2858,6 +2894,7 @@ static uint64_t gt_tval_read(CPUARMState *env, const ARMCPRegInfo *ri, switch (timeridx) { case GTIMER_VIRT: case GTIMER_HYPVIRT: + case GTIMER_SEC_VEL2: offset = gt_virt_cnt_offset(env); break; case GTIMER_PHYS: @@ -2878,6 +2915,7 @@ static void gt_tval_write(CPUARMState *env, const ARMCPRegInfo *ri, switch (timeridx) { case GTIMER_VIRT: case GTIMER_HYPVIRT: + case GTIMER_SEC_VEL2: offset = gt_virt_cnt_offset(env); break; case GTIMER_PHYS: @@ -3186,6 +3224,62 @@ static void gt_sec_ctl_write(CPUARMState *env, const ARMCPRegInfo *ri, gt_ctl_write(env, ri, GTIMER_SEC, value); } +static void gt_sec_pel2_timer_reset(CPUARMState *env, const ARMCPRegInfo *ri) +{ + gt_timer_reset(env, ri, GTIMER_SEC_PEL2); +} + +static void gt_sec_pel2_cval_write(CPUARMState *env, const ARMCPRegInfo *ri, + uint64_t value) +{ + gt_cval_write(env, ri, GTIMER_SEC_PEL2, value); +} + +static uint64_t gt_sec_pel2_tval_read(CPUARMState *env, const ARMCPRegInfo *ri) +{ + return gt_tval_read(env, ri, GTIMER_SEC_PEL2); +} + +static void gt_sec_pel2_tval_write(CPUARMState *env, const ARMCPRegInfo *ri, + uint64_t value) +{ + gt_tval_write(env, ri, GTIMER_SEC_PEL2, value); +} + +static void gt_sec_pel2_ctl_write(CPUARMState *env, const ARMCPRegInfo *ri, + uint64_t value) +{ + gt_ctl_write(env, ri, GTIMER_SEC_PEL2, value); +} + +static void gt_sec_vel2_timer_reset(CPUARMState *env, const ARMCPRegInfo *ri) +{ + gt_timer_reset(env, ri, GTIMER_SEC_VEL2); +} + +static void gt_sec_vel2_cval_write(CPUARMState *env, const ARMCPRegInfo *ri, + uint64_t value) +{ + gt_cval_write(env, ri, GTIMER_SEC_VEL2, value); +} + +static uint64_t gt_sec_vel2_tval_read(CPUARMState *env, const ARMCPRegInfo *ri) +{ + return gt_tval_read(env, ri, GTIMER_SEC_VEL2); +} + +static void gt_sec_vel2_tval_write(CPUARMState *env, const ARMCPRegInfo *ri, + uint64_t value) +{ + gt_tval_write(env, ri, GTIMER_SEC_VEL2, value); +} + +static void gt_sec_vel2_ctl_write(CPUARMState *env, const ARMCPRegInfo *ri, + uint64_t value) +{ + gt_ctl_write(env, ri, GTIMER_SEC_VEL2, value); +} + static void gt_hv_timer_reset(CPUARMState *env, const ARMCPRegInfo *ri) { gt_timer_reset(env, ri, GTIMER_HYPVIRT); @@ -3242,6 +3336,20 @@ void arm_gt_stimer_cb(void *opaque) gt_recalc_timer(cpu, GTIMER_SEC); } +void arm_gt_sel2timer_cb(void *opaque) +{ + ARMCPU *cpu = opaque; + + gt_recalc_timer(cpu, GTIMER_SEC_PEL2); +} + +void arm_gt_sel2vtimer_cb(void *opaque) +{ + ARMCPU *cpu = opaque; + + gt_recalc_timer(cpu, GTIMER_SEC_VEL2); +} + void arm_gt_hvtimer_cb(void *opaque) { ARMCPU *cpu = opaque; @@ -6624,6 +6732,56 @@ static const ARMCPRegInfo el2_sec_cp_reginfo[] = { .access = PL2_RW, .accessfn = sel2_access, .nv2_redirect_offset = 0x48, .fieldoffset = offsetof(CPUARMState, cp15.vstcr_el2) }, +#ifndef CONFIG_USER_ONLY + /* Secure EL2 Physical Timer */ + { .name = "CNTHPS_TVAL_EL2", .state = ARM_CP_STATE_AA64, + .opc0 = 3, .opc1 = 4, .crn = 14, .crm = 5, .opc2 = 0, + .type = ARM_CP_NO_RAW | ARM_CP_IO, .access = PL2_RW, + .accessfn = gt_sel2timer_access, + .readfn = gt_sec_pel2_tval_read, + .writefn = gt_sec_pel2_tval_write, + .resetfn = gt_sec_pel2_timer_reset, + }, + { .name = "CNTHPS_CTL_EL2", .state = ARM_CP_STATE_AA64, + .opc0 = 3, .opc1 = 4, .crn = 14, .crm = 5, .opc2 = 1, + .type = ARM_CP_IO, .access = PL2_RW, + .accessfn = gt_sel2timer_access, + .fieldoffset = offsetof(CPUARMState, cp15.c14_timer[GTIMER_SEC_PEL2].ctl), + .resetvalue = 0, + .writefn = gt_sec_pel2_ctl_write, .raw_writefn = raw_write, + }, + { .name = "CNTHPS_CVAL_EL2", .state = ARM_CP_STATE_AA64, + .opc0 = 3, .opc1 = 4, .crn = 14, .crm = 5, .opc2 = 2, + .type = ARM_CP_IO, .access = PL2_RW, + .accessfn = gt_sel2timer_access, + .fieldoffset = offsetof(CPUARMState, cp15.c14_timer[GTIMER_SEC_PEL2].cval), + .writefn = gt_sec_pel2_cval_write, .raw_writefn = raw_write, + }, + /* Secure EL2 Virtual Timer */ + { .name = "CNTHVS_TVAL_EL2", .state = ARM_CP_STATE_AA64, + .opc0 = 3, .opc1 = 4, .crn = 14, .crm = 4, .opc2 = 0, + .type = ARM_CP_NO_RAW | ARM_CP_IO, .access = PL2_RW, + .accessfn = gt_sel2timer_access, + .readfn = gt_sec_vel2_tval_read, + .writefn = gt_sec_vel2_tval_write, + .resetfn = gt_sec_vel2_timer_reset, + }, + { .name = "CNTHVS_CTL_EL2", .state = ARM_CP_STATE_AA64, + .opc0 = 3, .opc1 = 4, .crn = 14, .crm = 4, .opc2 = 1, + .type = ARM_CP_IO, .access = PL2_RW, + .accessfn = gt_sel2timer_access, + .fieldoffset = offsetof(CPUARMState, cp15.c14_timer[GTIMER_SEC_VEL2].ctl), + .resetvalue = 0, + .writefn = gt_sec_vel2_ctl_write, .raw_writefn = raw_write, + }, + { .name = "CNTHVS_CVAL_EL2", .state = ARM_CP_STATE_AA64, + .opc0 = 3, .opc1 = 4, .crn = 14, .crm = 4, .opc2 = 2, + .type = ARM_CP_IO, .access = PL2_RW, + .accessfn = gt_sel2timer_access, + .fieldoffset = offsetof(CPUARMState, cp15.c14_timer[GTIMER_SEC_VEL2].cval), + .writefn = gt_sec_vel2_cval_write, .raw_writefn = raw_write, + }, +#endif }; static CPAccessResult nsacr_access(CPUARMState *env, const ARMCPRegInfo *ri,