From patchwork Thu Dec 1 07:09:42 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vijay Kilari X-Patchwork-Id: 85961 Delivered-To: patch@linaro.org Received: by 10.140.20.101 with SMTP id 92csp569049qgi; Wed, 30 Nov 2016 23:12:12 -0800 (PST) X-Received: by 10.84.148.203 with SMTP id y11mr81900487plg.29.1480576332604; Wed, 30 Nov 2016 23:12:12 -0800 (PST) Return-Path: Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id i78si68232374pfk.182.2016.11.30.23.12.12 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 30 Nov 2016 23:12:12 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org designates 2001:1868:205::9 as permitted sender) client-ip=2001:1868:205::9; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com; spf=pass (google.com: best guess record for domain of linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org designates 2001:1868:205::9 as permitted sender) smtp.mailfrom=linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org; dmarc=fail (p=NONE dis=NONE) header.from=gmail.com Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1cCLWN-0000eV-22; Thu, 01 Dec 2016 07:11:07 +0000 Received: from mail-pg0-x243.google.com ([2607:f8b0:400e:c05::243]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1cCLVr-0007y9-T3 for linux-arm-kernel@lists.infradead.org; Thu, 01 Dec 2016 07:10:40 +0000 Received: by mail-pg0-x243.google.com with SMTP id 3so3748955pgd.0 for ; Wed, 30 Nov 2016 23:10:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=9s0S6yC+17x++Qd50Urg6aEg7tTfasBZyu6Jnt7wAP4=; b=KUw55/4wKJ1kiG/iNr7r5liMrVcqM/IXAXdGy9ovo1tb+KFp2jpmWTOgnVHdaP97zf BdilJ42QfVnBwbINqA4NY0Hc961BgH778HCAISjAZm/AO0mjdNHFHhCwqVoOrKtzLDMP BbY5oiOxYmLhA/5GrdoxCyelj4VGS+Cf2EUL+ssuJhtF7TztmrA0zgJclg0fqywdrmnm yi7VIvbxGW0c62Bjoc3gQ536g99gvNftOqZC6+IPieh79ClCoFAoFK9xN0tIquy8TTeF IhxMxfWsHsW+DDbnZg6h169YktzmWGVUYdoj1dUwqo/7t8Orhwx1ilPeH29HUcqlpzmH UjNw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=9s0S6yC+17x++Qd50Urg6aEg7tTfasBZyu6Jnt7wAP4=; b=NTtX61wx4KeBbbnt1+w07LQ8UoOECZaiem2b6Zmp5crjs2kEjxzpZU+LXq8lFSt8Z7 4w64TV6diOy3RJPYeSvVLXRy1r8dpmWUkMO+VNLjl/B5K0LXV/CnjLmskrvKcrAijgiU EboU+jwAX4YjmmeuTp6VdxjiuUIyv8aB/ZVBFsqSL3BmFV6yGIHsWz4VgCaVAYoGaBk9 bEmLqMDVGGOBgIN1Ql/dGuMf5m1GqlcCIV1BTLJYWYstWYYlljk647fK4f8ygh1+xSrA KAzBpUQMiA0p5f7lfto7uWvM/Jtk168Tb8ahsfOzIm6q+uwr01G7mJQiZXyA/i++ytrS h4zQ== X-Gm-Message-State: AKaTC02aMySYvdHXqwjsBVCQuJfB7gxjo/lKH9EKW7NjVcQcl1IbYaym7QwwPgjLtpJwSw== X-Received: by 10.98.222.194 with SMTP id h185mr37699927pfg.130.1480576214864; Wed, 30 Nov 2016 23:10:14 -0800 (PST) Received: from cavium-Vostro-2520.caveonetworks.com (50-233-148-156-static.hfc.comcastbusiness.net. [50.233.148.156]) by smtp.gmail.com with ESMTPSA id q9sm107696070pfg.47.2016.11.30.23.10.11 (version=TLS1_1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 30 Nov 2016 23:10:14 -0800 (PST) From: vijay.kilari@gmail.com To: marc.zyngier@arm.com, christoffer.dall@linaro.org, peter.maydell@linaro.org Subject: [PATCH v10 3/8] arm/arm64: vgic: Introduce find_reg_by_id() Date: Thu, 1 Dec 2016 12:39:42 +0530 Message-Id: <1480576187-5012-4-git-send-email-vijay.kilari@gmail.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1480576187-5012-1-git-send-email-vijay.kilari@gmail.com> References: <1480576187-5012-1-git-send-email-vijay.kilari@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20161130_231036_251938_331F861A X-CRM114-Status: GOOD ( 12.13 ) X-Spam-Score: -2.0 (--) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-2.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [2607:f8b0:400e:c05:0:0:0:243 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (vijay.kilari[at]gmail.com) -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: p.fedin@samsung.com, kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org, Vijaya Kumar K MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org From: Vijaya Kumar K In order to implement vGICv3 CPU interface access, we will need to perform table lookup of system registers. We would need both index_to_params() and find_reg() exported for that purpose, but instead we export a single function which combines them both. Signed-off-by: Pavel Fedin Signed-off-by: Vijaya Kumar K Reviewed-by: Andre Przywara Acked-by: Christoffer Dall --- arch/arm64/kvm/sys_regs.c | 22 +++++++++++++++------- arch/arm64/kvm/sys_regs.h | 4 ++++ 2 files changed, 19 insertions(+), 7 deletions(-) -- 1.9.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel diff --git a/arch/arm64/kvm/sys_regs.c b/arch/arm64/kvm/sys_regs.c index f302fdb..1330d4c 100644 --- a/arch/arm64/kvm/sys_regs.c +++ b/arch/arm64/kvm/sys_regs.c @@ -1789,6 +1789,17 @@ static bool index_to_params(u64 id, struct sys_reg_params *params) } } +const struct sys_reg_desc *find_reg_by_id(u64 id, + struct sys_reg_params *params, + const struct sys_reg_desc table[], + unsigned int num) +{ + if (!index_to_params(id, params)) + return NULL; + + return find_reg(params, table, num); +} + /* Decode an index value, and find the sys_reg_desc entry. */ static const struct sys_reg_desc *index_to_sys_reg_desc(struct kvm_vcpu *vcpu, u64 id) @@ -1912,10 +1923,8 @@ static int get_invariant_sys_reg(u64 id, void __user *uaddr) struct sys_reg_params params; const struct sys_reg_desc *r; - if (!index_to_params(id, ¶ms)) - return -ENOENT; - - r = find_reg(¶ms, invariant_sys_regs, ARRAY_SIZE(invariant_sys_regs)); + r = find_reg_by_id(id, ¶ms, invariant_sys_regs, + ARRAY_SIZE(invariant_sys_regs)); if (!r) return -ENOENT; @@ -1929,9 +1938,8 @@ static int set_invariant_sys_reg(u64 id, void __user *uaddr) int err; u64 val = 0; /* Make sure high bits are 0 for 32-bit regs */ - if (!index_to_params(id, ¶ms)) - return -ENOENT; - r = find_reg(¶ms, invariant_sys_regs, ARRAY_SIZE(invariant_sys_regs)); + r = find_reg_by_id(id, ¶ms, invariant_sys_regs, + ARRAY_SIZE(invariant_sys_regs)); if (!r) return -ENOENT; diff --git a/arch/arm64/kvm/sys_regs.h b/arch/arm64/kvm/sys_regs.h index dbbb01c..9c6ffd0 100644 --- a/arch/arm64/kvm/sys_regs.h +++ b/arch/arm64/kvm/sys_regs.h @@ -136,6 +136,10 @@ static inline int cmp_sys_reg(const struct sys_reg_desc *i1, return i1->Op2 - i2->Op2; } +const struct sys_reg_desc *find_reg_by_id(u64 id, + struct sys_reg_params *params, + const struct sys_reg_desc table[], + unsigned int num); #define Op0(_x) .Op0 = _x #define Op1(_x) .Op1 = _x