From patchwork Tue Dec 19 19:12:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 755951 Delivered-To: patch@linaro.org Received: by 2002:adf:b181:0:b0:336:6142:bf13 with SMTP id q1csp1600782wra; Tue, 19 Dec 2023 11:15:32 -0800 (PST) X-Google-Smtp-Source: AGHT+IEWAtqGifJSNoXvdNytOSStw/07ORrRFwfcsN3z72dDx8h/rKnasTAqjgi/9WUD6XFK0Gce X-Received: by 2002:a05:6102:3565:b0:466:5d4d:ecd6 with SMTP id bh5-20020a056102356500b004665d4decd6mr6105437vsb.16.1703013332246; Tue, 19 Dec 2023 11:15:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703013332; cv=none; d=google.com; s=arc-20160816; b=v/Qn6/hFy5efiFWMewLRfXJiihZrlSHJ/jSugMnRTs6sJ88Hae3K0YAMgeVCcP7Ard F4BVZRdzTu2nFKnBX3eTd913nizoOsuyzXiq/XZVx4tcOW+HE1YXkgQHVTaDLIDZCX8v As00AA7kvAwU/QhrILIQCwWxJ2UJLaxYWrw8GgHt3yWDSVeHvFPn/hpm2BdaHb3vtLMG QgatJwEValeeT2vl1bidN+/paAUJUI0P0Uvybvz969pxrea7rf/KrXbtVg2O+/ub61cu saAmhLvpc/hl9Qjgj9JER0qlI8F0jXLMI5qF2QQ2fQORgn570kkuvzwANH+bQI5c17Fh oBwg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=8U4Zs7qJxd6knz6FwIYeN/wpMsd6G/tgH0Hh4NzLuf8=; fh=PnYt+qEB9tAfMKoqBm2xjKOFpYyFFGPudh5cVIoieJM=; b=FJwgMVy/Ynma7a9g42J14jbSVSZj4om2B0ffi1EwqiI3ceGUtgREPzph3VMGfUBvAv x/wJVkZaGepUPFHKgLvN4Z67hYtaVZV7/k/+dYxgBN7ru+ktzm37ZGAA8Vj6YS8okJYd gShaub69UHS4dv6/vRq04AR+4R7SfbTip3tKdJPWyXvyXZ+7YOsWBt/33lB7ShRjMIvs zktAKmR5/WgDKkp1NTu5RRCpokTl8DsDtWgSpbU0tENUXqG08BFWpP0RDIBemHYru7xc 0aS1b53MZKiWOcHeEUkz0QvF460kqmqSBqLQPDAlRRUJMhkvKdoPH21H1kI6Bs+jZ4bi igzw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=hFRYK+EZ; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id v19-20020a67f1d3000000b004668e1dda6bsi966236vsm.676.2023.12.19.11.15.32 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 19 Dec 2023 11:15:32 -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=hFRYK+EZ; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rFfWr-0001qP-6o; Tue, 19 Dec 2023 14:13:21 -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 1rFfWn-0001mm-RI for qemu-devel@nongnu.org; Tue, 19 Dec 2023 14:13:17 -0500 Received: from mail-wr1-x435.google.com ([2a00:1450:4864:20::435]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rFfWm-0001mV-4T for qemu-devel@nongnu.org; Tue, 19 Dec 2023 14:13:17 -0500 Received: by mail-wr1-x435.google.com with SMTP id ffacd0b85a97d-3365752934bso3970994f8f.2 for ; Tue, 19 Dec 2023 11:13:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1703013195; x=1703617995; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=8U4Zs7qJxd6knz6FwIYeN/wpMsd6G/tgH0Hh4NzLuf8=; b=hFRYK+EZzJlMEj1vJrSHIrtegxjCqDKtl6c0uvqwddXz/q1ktdKV8VWbH3Ip3vC15d uGV8lVfcoeG4O66uVIiyyYXjdEmA64db/JRidmZ5PZzlrpSnCvQ5MFYEkJGOaCLwcPHG Gqz6t6K6y9qz4DIdiIxOdtuayLO600pLzjNCMTt3arFxr67++8VLAK8eTVbBSuZQi8aY syvUIAXsM7Yb5Eqk/xnxMyxDSumTnq/4oCkZ+6BT6LJqbDuu1FD6emHkkZZYMpIybmD0 N9TptXU+xeOmtQ8/8EZtnDTlHMZ9ad/qLLSGIsQseGJA+RGZu73x0ikdE+LRsy0kVJ0V 7KUA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703013195; x=1703617995; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=8U4Zs7qJxd6knz6FwIYeN/wpMsd6G/tgH0Hh4NzLuf8=; b=XkzaPZFgN2lY+S2qwPDbpRruXB7SwIWoZCZR41eOqCYVy5orWPXgHfsNq8K4rh9oUa +JKZy/TrWMn02yYvffiOp2nTow28yu/aF6dGHXxxBcZh2heAkwKGxM2+J1BmzVXzMbFc V74s9NQPWnk8g152eEKUsxWGoPpg0lH6az534otr+auu/3VFnQsJKUyMkYAJEcDH3GFF ktcDBs8PKnm/RLV0A5t/PZmzrHyrl9L/fasOBf+ZhJaIGnJg8oR8Fza3a1C02dhono5P IeVFJj4NoXLD4Kaypm98sbq5pVvCWRE3ZyXfJ8n3sMYh7MDQDMfEawr4RWA5QKeLjbyE ihsw== X-Gm-Message-State: AOJu0Yy1g7f8qJmfhRxRJH8/FamPCrXkDb1QgvpVc+1F016bz5Z7V9tR 8d9oQQ8y3FYXpYcP+aRyTaPi/v/gqbEI1eN+H1U= X-Received: by 2002:a5d:4c4a:0:b0:336:7793:6ab2 with SMTP id n10-20020a5d4c4a000000b0033677936ab2mr297538wrt.143.1703013194661; Tue, 19 Dec 2023 11:13:14 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id f5-20020a5d5685000000b0033657376b62sm12007754wrv.105.2023.12.19.11.13.14 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Dec 2023 11:13:14 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 11/43] target/arm/kvm: Use a switch for kvm_arm_cpreg_level Date: Tue, 19 Dec 2023 19:12:35 +0000 Message-Id: <20231219191307.2895919-12-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231219191307.2895919-1-peter.maydell@linaro.org> References: <20231219191307.2895919-1-peter.maydell@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::435; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x435.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, T_SCC_BODY_TEXT_LINE=-0.01 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 From: Richard Henderson Use a switch instead of a linear search through data. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé Tested-by: Philippe Mathieu-Daudé Signed-off-by: Peter Maydell --- target/arm/kvm64.c | 32 +++++++++----------------------- 1 file changed, 9 insertions(+), 23 deletions(-) diff --git a/target/arm/kvm64.c b/target/arm/kvm64.c index 504526b24c9..61fb9dbde0e 100644 --- a/target/arm/kvm64.c +++ b/target/arm/kvm64.c @@ -361,32 +361,18 @@ bool kvm_arm_reg_syncs_via_cpreg_list(uint64_t regidx) } } -typedef struct CPRegStateLevel { - uint64_t regidx; - int level; -} CPRegStateLevel; - -/* All system registers not listed in the following table are assumed to be - * of the level KVM_PUT_RUNTIME_STATE. If a register should be written less - * often, you must add it to this table with a state of either - * KVM_PUT_RESET_STATE or KVM_PUT_FULL_STATE. - */ -static const CPRegStateLevel non_runtime_cpregs[] = { - { KVM_REG_ARM_TIMER_CNT, KVM_PUT_FULL_STATE }, - { KVM_REG_ARM_PTIMER_CNT, KVM_PUT_FULL_STATE }, -}; - int kvm_arm_cpreg_level(uint64_t regidx) { - int i; - - for (i = 0; i < ARRAY_SIZE(non_runtime_cpregs); i++) { - const CPRegStateLevel *l = &non_runtime_cpregs[i]; - if (l->regidx == regidx) { - return l->level; - } + /* + * All system registers are assumed to be level KVM_PUT_RUNTIME_STATE. + * If a register should be written less often, you must add it here + * with a state of either KVM_PUT_RESET_STATE or KVM_PUT_FULL_STATE. + */ + switch (regidx) { + case KVM_REG_ARM_TIMER_CNT: + case KVM_REG_ARM_PTIMER_CNT: + return KVM_PUT_FULL_STATE; } - return KVM_PUT_RUNTIME_STATE; }