From patchwork Wed Nov 23 13:01:57 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vijay Kilari X-Patchwork-Id: 83661 Delivered-To: patch@linaro.org Received: by 10.140.97.165 with SMTP id m34csp2626340qge; Wed, 23 Nov 2016 05:08:27 -0800 (PST) X-Received: by 10.99.163.1 with SMTP id s1mr5115159pge.120.1479906507723; Wed, 23 Nov 2016 05:08:27 -0800 (PST) Return-Path: Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id n1si33727541pgc.121.2016.11.23.05.08.27 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 23 Nov 2016 05:08:27 -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 1c9XGa-0008HH-IP; Wed, 23 Nov 2016 13:07:12 +0000 Received: from mail-pf0-x244.google.com ([2607:f8b0:400e:c00::244]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1c9XCR-00041c-AH for linux-arm-kernel@lists.infradead.org; Wed, 23 Nov 2016 13:02:57 +0000 Received: by mail-pf0-x244.google.com with SMTP id y68so704103pfb.1 for ; Wed, 23 Nov 2016 05:02:38 -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=OWuEjx22Psv+m9ndG2LDLIjiOCRur5cXk+r1cWZvg0E=; b=aKAIYDZDJby/b8NrYn7gzRyN+KrCPjrWkPEb0vOEeXT/qgI+k9EpVL4T9QgYME99ub 1HAA9PJFEuFBUtO25ER+Ef7Q+BypF4sg7N2KOrJ2pc05HS0xj99bsAl7VeQtydo7Y5hT CXhSdUfsybQmECLQk231p5K40Q8sjroWjCuPqXrDeEbw6AYjr5/hiCaBEosJH7PZGbBy MyUoIObd/Yuq4KIB+CTYhb2pn8YMhFK4j9gqRJvpDLGRc+y36FSPVxjm0HB3AKnp9sdu 0E1BHAWBZUcrtLQy0D2pc1bmlzJnvVozcvPvWx0gOzVGd4JsDVMwlDvVx2Z3UTR1lJ1z BV5w== 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=OWuEjx22Psv+m9ndG2LDLIjiOCRur5cXk+r1cWZvg0E=; b=HDWPvTweDqocUjKiWVrfGryfkUItcGLGdjLFz/JzuV8CLBCK3Fit2TV0UC2GALaDq3 vEAwbilKTv5K6MaccQI6vM1y7LjkHJpdI6QNSivspmix4hLRVQsDLMYF8EUnWsgcxSkS X5Yv7vyOZrcdRE22wJq4YQ1ztAaHvimrIGOEyQjPZAwN/smdi3D7TymfNNJSVWFYIg1J zVrIXbkic9Sa8dzbmyADwOkuAfsRelXr1PywG/Y0qFmD73BVS2I/AZZAfX+TrcLQt4EN 1KckUjN3p0tfJ3dsrBLKAT4LQlE1DqU2ZCuNyp2lrG8glHUh7yi62z6Js1jDkCCEUmNS 0dQg== X-Gm-Message-State: AKaTC03UiN6xIRubQj3hb+UFKegja1ZCnfG3098TOMoqlE10ayFpUXFEMJiVP1fRx33d9g== X-Received: by 10.84.197.1 with SMTP id m1mr6468343pld.159.1479906158210; Wed, 23 Nov 2016 05:02:38 -0800 (PST) Received: from cavium-Vostro-2520.caveonetworks.com ([111.93.218.67]) by smtp.gmail.com with ESMTPSA id a24sm36838849pfh.57.2016.11.23.05.02.35 (version=TLS1_1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 23 Nov 2016 05:02:37 -0800 (PST) From: vijay.kilari@gmail.com To: marc.zyngier@arm.com, christoffer.dall@linaro.org, peter.maydell@linaro.org Subject: [PATCH v9 10/11] arm: coproc: Introduce find_coproc_reg_by_id() Date: Wed, 23 Nov 2016 18:31:57 +0530 Message-Id: <1479906118-15832-11-git-send-email-vijay.kilari@gmail.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1479906118-15832-1-git-send-email-vijay.kilari@gmail.com> References: <1479906118-15832-1-git-send-email-vijay.kilari@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20161123_050255_661396_F1FBC86F X-CRM114-Status: GOOD ( 11.74 ) 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:c00:0:0:0:244 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: 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 To access CPU interface access in AArch32 mode, we need to perform coproc_reg table lookup. For this introduce find_coproc_reg_by_id() and export. Also use this function internally in coproc.c wherever required. Signed-off-by: Vijaya Kumar K --- arch/arm/kvm/coproc.c | 22 +++++++++++++++------- arch/arm/kvm/coproc.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/arm/kvm/coproc.c b/arch/arm/kvm/coproc.c index 5753926..7d05700 100644 --- a/arch/arm/kvm/coproc.c +++ b/arch/arm/kvm/coproc.c @@ -616,6 +616,17 @@ static bool index_to_params(u64 id, struct coproc_params *params) } } +const struct coproc_reg * +find_coproc_reg_by_id(u64 id, struct coproc_params *params, + const struct coproc_reg 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 cp15 coproc_reg entry. */ static const struct coproc_reg *index_to_coproc_reg(struct kvm_vcpu *vcpu, u64 id) @@ -742,10 +753,8 @@ static int get_invariant_cp15(u64 id, void __user *uaddr) const struct coproc_reg *r; int ret; - if (!index_to_params(id, ¶ms)) - return -ENOENT; - - r = find_reg(¶ms, invariant_cp15, ARRAY_SIZE(invariant_cp15)); + r = find_coproc_reg_by_id(id, ¶ms, invariant_cp15, + ARRAY_SIZE(invariant_cp15)); if (!r) return -ENOENT; @@ -767,9 +776,8 @@ static int set_invariant_cp15(u64 id, void __user *uaddr) int err; u64 val; - if (!index_to_params(id, ¶ms)) - return -ENOENT; - r = find_reg(¶ms, invariant_cp15, ARRAY_SIZE(invariant_cp15)); + r = find_coproc_reg_by_id(id, ¶ms, invariant_cp15, + ARRAY_SIZE(invariant_cp15)); if (!r) return -ENOENT; diff --git a/arch/arm/kvm/coproc.h b/arch/arm/kvm/coproc.h index bbeff2a..2accd9d 100644 --- a/arch/arm/kvm/coproc.h +++ b/arch/arm/kvm/coproc.h @@ -157,4 +157,8 @@ bool access_vm_reg(struct kvm_vcpu *vcpu, struct coproc_params *p, const struct coproc_reg *r); +const struct coproc_reg * +find_coproc_reg_by_id(u64 id, struct coproc_params *params, + const struct coproc_reg table[], + unsigned int num); #endif /* __ARM_KVM_COPROC_LOCAL_H__ */