From patchwork Tue Aug 9 10:58:45 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vijay Kilari X-Patchwork-Id: 73538 Delivered-To: patch@linaro.org Received: by 10.140.29.52 with SMTP id a49csp421774qga; Tue, 9 Aug 2016 04:01:22 -0700 (PDT) X-Received: by 10.66.41.133 with SMTP id f5mr172853508pal.70.1470740482189; Tue, 09 Aug 2016 04:01:22 -0700 (PDT) Return-Path: Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id d139si42225816pfd.10.2016.08.09.04.01.22 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 09 Aug 2016 04:01:22 -0700 (PDT) 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 1bX4lf-0006wN-RT; Tue, 09 Aug 2016 11:00:19 +0000 Received: from mail-pa0-x241.google.com ([2607:f8b0:400e:c03::241]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1bX4l7-00064p-2b for linux-arm-kernel@lists.infradead.org; Tue, 09 Aug 2016 10:59:47 +0000 Received: by mail-pa0-x241.google.com with SMTP id vy10so784544pac.0 for ; Tue, 09 Aug 2016 03:59:26 -0700 (PDT) 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=Pmu+sUKnW0YvPR749Pv5yaiF1C7Fw7tFpi8e0HH2Gfg=; b=mTGaYo0G9N1BJqBqK24Fxa+kynzbMlr7oH6hEaqOq8VZGFb4KgAmMuw+pYDKwtP5ol 2PGkSuORzTopofrEoeAkq044CP1e8S/tGYomAfLNg5fm2pd7qggqRLWL0uHfsPGzZL43 vHj1VxFQSG/6KNdaqfs3HcNcL0CAAIzPxzPTPrjxD9RoJ0TjpFgsJglkB/zWZvnrDCDs YkCqsmDL7QXLle5HYpPjk+KcGjK6WN0PYLNB82oXrjk/CNRGMTa4xoQlZEyxydmN7GOt 6cY9gwgQ7cSBVjEz8WVBlVDuyu8hSCV2M/nFrRDdc69I+dKioVE+pmRrfj8NxEmfH4mW uv1g== 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=Pmu+sUKnW0YvPR749Pv5yaiF1C7Fw7tFpi8e0HH2Gfg=; b=NI7BFSun5ngx8WtZo7dT34C2eYVWp2gQlmn8k+AIBJcWGoqf3cFuPBEBQuF51pZFnr kp5eipesq3eRwGx8qNGAfOoPrmL9LEQbrzauNhflSoIRAojV4HZ6eIG6gY+r7Uofmpkw 4WVHBPuubGI478D6FjLj4dQFoOTEj/G57Pwl4Rn0gbXWpDsp9Ikz/z629rl3xA1trr75 Bl1TbzQCe35gUTSVl0647o9jFimNo5ScjJVTHHnN6nzsB7ZUyNYnN01HKXWDrdx9dFvG mX1hK5e1xzezhg3/rZ5ogRMqRBEimOmyJDvIeMLSvzVNJEoRXbZh/IWCjnxL0yI53Mmh PE2g== X-Gm-Message-State: AEkooutUpsmyU2D0PWl7QIoF9QxAWRTnttkMiOzPacdQnOAi07dJuFRc7VYKYcRpLqz15Q== X-Received: by 10.66.154.232 with SMTP id vr8mr170447825pab.104.1470740365863; Tue, 09 Aug 2016 03:59:25 -0700 (PDT) Received: from cavium-Vostro-2520.caveonetworks.com ([111.93.218.67]) by smtp.gmail.com with ESMTPSA id o80sm55076202pfa.67.2016.08.09.03.59.23 (version=TLS1_1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 09 Aug 2016 03:59:25 -0700 (PDT) From: vijay.kilari@gmail.com To: marc.zyngier@arm.com, christoffer.dall@linaro.org Subject: [RFC PATCH v2 3/4] arm/arm64: vgic-new: Introduce find_reg_by_id() Date: Tue, 9 Aug 2016 16:28:45 +0530 Message-Id: <1470740326-27751-4-git-send-email-vijay.kilari@gmail.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1470740326-27751-1-git-send-email-vijay.kilari@gmail.com> References: <1470740326-27751-1-git-send-email-vijay.kilari@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160809_035945_307129_B876C784 X-CRM114-Status: GOOD ( 13.03 ) X-Spam-Score: -0.6 (/) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-0.6 points) pts rule name description ---- ---------------------- -------------------------------------------------- 0.8 RCVD_IN_SORBS_WEB RBL: SORBS: sender is an abusable web server [111.93.218.67 listed in dnsbl.sorbs.net] -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [2607:f8b0:400e:c03:0:0:0:241 listed in] [list.dnswl.org] 1.3 RCVD_IN_BL_SPAMCOP_NET RBL: Received via a relay in bl.spamcop.net [Blocked - see ] -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: Prasun.Kapoor@cavium.com, 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 Reviewed-by: Andre Przywara Signed-off-by: Vijaya Kumar K --- 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 a57d650..16c33ca 100644 --- a/arch/arm64/kvm/sys_regs.c +++ b/arch/arm64/kvm/sys_regs.c @@ -1802,6 +1802,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) @@ -1929,10 +1940,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; @@ -1946,9 +1955,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