From patchwork Tue Aug 26 14:13:22 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Will Deacon X-Patchwork-Id: 36034 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-qg0-f71.google.com (mail-qg0-f71.google.com [209.85.192.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 5D8A52054F for ; Tue, 26 Aug 2014 14:16:57 +0000 (UTC) Received: by mail-qg0-f71.google.com with SMTP id f51sf45564158qge.10 for ; Tue, 26 Aug 2014 07:16:57 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:subject:date:message-id :in-reply-to:references:cc:precedence:list-id:list-unsubscribe :list-archive:list-post:list-help:list-subscribe:mime-version:sender :errors-to:x-original-sender:x-original-authentication-results :mailing-list:content-type:content-transfer-encoding; bh=JHYoHKezAjgmpeq9nMhm2gfKMtHKBWf/VpcTaJ2dgrY=; b=dIGAo9CixgPPzJvBaWO4z2cihuXevuoTQlzp2n//hzbs9eyPGblLLvAC0BjBbR5Ze4 qscLMue6u67RUCMecthl0cFlgZImktakEL5jrNxjxj2AggXV0vXYaXfoXjtGuVdDrYus Zlpa1jVwWjY31MO7EsOcUsxVjH2e+vOLY0MgDK69ovJvOAISaK7RCp1ImiufoF3MviTA k10wqS4nHAKta0mIS4Wf62ENM3Y+QAEuT6lNLg94uAbBrWS0v4V1Im9vu0KM8llQBVrc WTEdy3KC/lC+aTWITLZG3uiiWcD3TlAi8vG7FjHn7Bo8RPDnsHlR5QxSo7RYhLR8pcWU B9/g== X-Gm-Message-State: ALoCoQkFB0p0axU3nlCLfdvUjQkwdUjZ1kWAPo/CsvwV8fpPAlDSECzgYZNmIggfjzmk8oOdD8iO X-Received: by 10.236.117.141 with SMTP id j13mr5274750yhh.3.1409062617217; Tue, 26 Aug 2014 07:16:57 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.38.176 with SMTP id t45ls2494918qgt.60.gmail; Tue, 26 Aug 2014 07:16:56 -0700 (PDT) X-Received: by 10.236.123.114 with SMTP id u78mr2790728yhh.107.1409062616917; Tue, 26 Aug 2014 07:16:56 -0700 (PDT) Received: from mail-yk0-f182.google.com (mail-yk0-f182.google.com [209.85.160.182]) by mx.google.com with ESMTPS id t32si2400022yho.197.2014.08.26.07.16.56 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 26 Aug 2014 07:16:56 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.160.182 as permitted sender) client-ip=209.85.160.182; Received: by mail-yk0-f182.google.com with SMTP id q9so11407534ykb.13 for ; Tue, 26 Aug 2014 07:16:56 -0700 (PDT) X-Received: by 10.220.77.65 with SMTP id f1mr1165714vck.48.1409062616820; Tue, 26 Aug 2014 07:16:56 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.221.45.67 with SMTP id uj3csp202864vcb; Tue, 26 Aug 2014 07:16:56 -0700 (PDT) X-Received: by 10.70.128.65 with SMTP id nm1mr37389096pdb.15.1409062614886; Tue, 26 Aug 2014 07:16:54 -0700 (PDT) Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id mi6si3101319pab.17.2014.08.26.07.16.54 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 26 Aug 2014 07:16:54 -0700 (PDT) Received-SPF: none (google.com: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org does not designate permitted sender hosts) client-ip=2001:1868:205::9; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1XMHXD-0003vx-R2; Tue, 26 Aug 2014 14:15:43 +0000 Received: from cam-admin0.cambridge.arm.com ([217.140.96.50]) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1XMHVG-000878-NH for linux-arm-kernel@lists.infradead.org; Tue, 26 Aug 2014 14:13:43 +0000 Received: from edgewater-inn.cambridge.arm.com (edgewater-inn.cambridge.arm.com [10.1.203.34]) by cam-admin0.cambridge.arm.com (8.12.6/8.12.6) with ESMTP id s7QEDHwo011794; Tue, 26 Aug 2014 15:13:17 +0100 (BST) Received: by edgewater-inn.cambridge.arm.com (Postfix, from userid 1000) id 7B2181AE067C; Tue, 26 Aug 2014 15:13:37 +0100 (BST) From: Will Deacon To: linux-arm-kernel@lists.infradead.org Subject: [PATCH 03/11] KVM: ARM/arm64: avoid returning negative error code as bool Date: Tue, 26 Aug 2014 15:13:22 +0100 Message-Id: <1409062410-25891-4-git-send-email-will.deacon@arm.com> X-Mailer: git-send-email 2.1.0.rc1 In-Reply-To: <1409062410-25891-1-git-send-email-will.deacon@arm.com> References: <1409062410-25891-1-git-send-email-will.deacon@arm.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140826_071343_174190_3E9E9BD1 X-CRM114-Status: GOOD ( 10.72 ) X-Spam-Score: -5.0 (-----) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-5.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -5.0 RCVD_IN_DNSWL_HI RBL: Sender listed at http://www.dnswl.org/, high trust [217.140.96.50 listed in list.dnswl.org] 0.0 RP_MATCHES_RCVD Envelope sender domain matches handover relay domain -0.0 SPF_PASS SPF: sender matches SPF record Cc: Marc Zyngier , catalin.marinas@arm.com, Will Deacon , Christoffer Dall X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: will.deacon@arm.com X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.160.182 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 is_valid_cache returns true if the specified cache is valid. Unfortunately, if the parameter passed it out of range, we return -ENOENT, which ends up as true leading to potential hilarity. This patch returns false on the failure path instead. Cc: Christoffer Dall Cc: Marc Zyngier Signed-off-by: Will Deacon Acked-by: Marc Zyngier Acked-by: Christoffer Dall --- arch/arm/kvm/coproc.c | 2 +- arch/arm64/kvm/sys_regs.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/arm/kvm/coproc.c b/arch/arm/kvm/coproc.c index 37a0fe1bb9bb..7928dbdf2102 100644 --- a/arch/arm/kvm/coproc.c +++ b/arch/arm/kvm/coproc.c @@ -791,7 +791,7 @@ static bool is_valid_cache(u32 val) u32 level, ctype; if (val >= CSSELR_MAX) - return -ENOENT; + return false; /* Bottom bit is Instruction or Data bit. Next 3 bits are level. */ level = (val >> 1); diff --git a/arch/arm64/kvm/sys_regs.c b/arch/arm64/kvm/sys_regs.c index 5805e7c4a4dd..4cc3b719208e 100644 --- a/arch/arm64/kvm/sys_regs.c +++ b/arch/arm64/kvm/sys_regs.c @@ -1218,7 +1218,7 @@ static bool is_valid_cache(u32 val) u32 level, ctype; if (val >= CSSELR_MAX) - return -ENOENT; + return false; /* Bottom bit is Instruction or Data bit. Next 3 bits are level. */ level = (val >> 1);