From patchwork Fri Sep 26 13:16:38 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoffer Dall X-Patchwork-Id: 37971 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f197.google.com (mail-lb0-f197.google.com [209.85.217.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id EB77C202DB for ; Fri, 26 Sep 2014 13:20:37 +0000 (UTC) Received: by mail-lb0-f197.google.com with SMTP id l4sf7542104lbv.8 for ; Fri, 26 Sep 2014 06:20:36 -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=7f3BBqiZS2+zznWpmSImXZWtG50c17btUS+fTULayVE=; b=HqeME+h0q2no9VlQ2v1CRAgTw9Y7KItIwNI/3h32WZQOBNxGRWrewJPGtMaYNAkMeS OfdH68ipB33/hJQZsl8UPWQ9Qzvo8KPp4XFsdCFJCV+J5e1YDpnvnFyboWqxv6QSZUQ/ WSXRFbf7a98bdxM8pZyEQ7bJjazW5JxVodwlTjxLacJgJytVpRthc8L5DVwoyep+5676 JX6aOfgbuMiWhAOLR7urdGSj7Je45Pict+Ow8Os+iusAMIFVbxoMUh6kOmmCE8gAhFbc HvR6yQbUDK/TaIJ9zOwlJEbqi+4rvwh8AXwsXHBq1fpl2Ubxc5mb2xTbbUC08z3pTNyD v3Sw== X-Gm-Message-State: ALoCoQmVkNGO+sNwsNPOMCniEzpO69d+AJtLcOiOAvbanBR7h1fUIzc2cAr1QqG0eIyyhv9uHAPh X-Received: by 10.112.126.228 with SMTP id nb4mr374334lbb.16.1411737636722; Fri, 26 Sep 2014 06:20:36 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.153.6.2 with SMTP id cq2ls370988lad.102.gmail; Fri, 26 Sep 2014 06:20:36 -0700 (PDT) X-Received: by 10.112.9.234 with SMTP id d10mr2815406lbb.98.1411737636578; Fri, 26 Sep 2014 06:20:36 -0700 (PDT) Received: from mail-lb0-f179.google.com (mail-lb0-f179.google.com [209.85.217.179]) by mx.google.com with ESMTPS id n5si7140370lbc.90.2014.09.26.06.20.36 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 26 Sep 2014 06:20:36 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.179 as permitted sender) client-ip=209.85.217.179; Received: by mail-lb0-f179.google.com with SMTP id 10so13699864lbg.38 for ; Fri, 26 Sep 2014 06:20:36 -0700 (PDT) X-Received: by 10.152.88.16 with SMTP id bc16mr802512lab.56.1411737635417; Fri, 26 Sep 2014 06:20:35 -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.112.130.169 with SMTP id of9csp59367lbb; Fri, 26 Sep 2014 06:20:34 -0700 (PDT) X-Received: by 10.68.220.228 with SMTP id pz4mr32045710pbc.16.1411737633922; Fri, 26 Sep 2014 06:20:33 -0700 (PDT) Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id qh12si9192653pab.181.2014.09.26.06.20.33 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 26 Sep 2014 06:20:33 -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 1XXVQJ-0003cD-Rq; Fri, 26 Sep 2014 13:18:59 +0000 Received: from mail-lb0-f172.google.com ([209.85.217.172]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1XXVPS-0002ay-Fj for linux-arm-kernel@lists.infradead.org; Fri, 26 Sep 2014 13:18:07 +0000 Received: by mail-lb0-f172.google.com with SMTP id p9so13977550lbv.3 for ; Fri, 26 Sep 2014 06:17:43 -0700 (PDT) X-Received: by 10.112.54.169 with SMTP id k9mr19778874lbp.32.1411737463821; Fri, 26 Sep 2014 06:17:43 -0700 (PDT) Received: from localhost.localdomain (188-178-240-98-static.dk.customer.tdc.net. [188.178.240.98]) by mx.google.com with ESMTPSA id z4sm1876657laz.39.2014.09.26.06.17.42 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 26 Sep 2014 06:17:43 -0700 (PDT) From: Christoffer Dall To: Paolo Bonzini , Gleb Natapov Subject: [PATCH 05/27] KVM: ARM/arm64: avoid returning negative error code as bool Date: Fri, 26 Sep 2014 15:16:38 +0200 Message-Id: <1411737420-9063-6-git-send-email-christoffer.dall@linaro.org> X-Mailer: git-send-email 2.0.0 In-Reply-To: <1411737420-9063-1-git-send-email-christoffer.dall@linaro.org> References: <1411737420-9063-1-git-send-email-christoffer.dall@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140926_061806_714669_665FC74E X-CRM114-Status: GOOD ( 11.49 ) X-Spam-Score: -0.9 (/) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-0.9 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [209.85.217.172 listed in list.dnswl.org] -0.2 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [209.85.217.172 listed in wl.mailspike.net] -0.0 SPF_PASS SPF: sender matches SPF record Cc: kvm@vger.kernel.org, Marc Zyngier , Will Deacon , Christoffer Dall , kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org 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: christoffer.dall@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.179 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 From: Will Deacon 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 Signed-off-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 37a0fe1..7928dbd 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 5805e7c..4cc3b71 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);