From patchwork Fri Apr 24 05:27:40 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shannon Zhao X-Patchwork-Id: 47527 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wg0-f69.google.com (mail-wg0-f69.google.com [74.125.82.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 35C8620553 for ; Fri, 24 Apr 2015 05:33:37 +0000 (UTC) Received: by wghm4 with SMTP id m4sf9144910wgh.2 for ; Thu, 23 Apr 2015 22:33: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:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe; bh=SzlO/ehl6gu7roVq1k63iQl3IStEyWka+LAxCud6FxQ=; b=hYPjkPGNFsd8SAKpwNPTh39SyT7hpWuH5RCzIqAKof/XnMfQGz/ojeCU6c1Ke8XWn5 fbPFPVSJIHyLCSNPLu1NVN1g8hGvD0Z2x8DSRF4SnxxnJ+SjJeFbyfuMX9/9979uO+ql ZoyEHJZbH4VH3tkwRX/AEMWcV96noIOvT/vITqu+pi3xNhjv1T3uHQFr7GpPH63YkvQo 7z8lAQF1zjTjICqTCeQF1Ig4Ic51c0RPhh/gD9ZIYxRp83Il3wRFkxIp/lkwuwmQG48t 4Z6Fy+rvX8md9QPuMtRHY5hxz046fTWwXeqOPnxU0uHgSwE2mkd+TOa12fHLOev+cV8K +pPQ== X-Gm-Message-State: ALoCoQn1kkjkoIdMRIb+vyqlzxIgEA7AuVYiDZuLPKU7u22OUFT6dOR+6xDs6olMzhCMz/Ua9jtc X-Received: by 10.180.97.9 with SMTP id dw9mr175930wib.2.1429853616480; Thu, 23 Apr 2015 22:33:36 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.37.105 with SMTP id x9ls448481laj.11.gmail; Thu, 23 Apr 2015 22:33:36 -0700 (PDT) X-Received: by 10.152.1.227 with SMTP id 3mr5407088lap.61.1429853616140; Thu, 23 Apr 2015 22:33: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 q16si7483154laa.25.2015.04.23.22.33.36 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 23 Apr 2015 22:33: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 lbcga7 with SMTP id ga7so28635915lbc.1 for ; Thu, 23 Apr 2015 22:33:36 -0700 (PDT) X-Received: by 10.112.184.70 with SMTP id es6mr5350047lbc.117.1429853616053; Thu, 23 Apr 2015 22:33:36 -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.67.65 with SMTP id l1csp978481lbt; Thu, 23 Apr 2015 22:33:35 -0700 (PDT) X-Received: by 10.68.94.129 with SMTP id dc1mr11790866pbb.8.1429853614309; Thu, 23 Apr 2015 22:33:34 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id bd10si15800741pdb.178.2015.04.23.22.33.33; Thu, 23 Apr 2015 22:33:34 -0700 (PDT) Received-SPF: none (google.com: stable-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754555AbbDXFdd (ORCPT + 2 others); Fri, 24 Apr 2015 01:33:33 -0400 Received: from mail-oi0-f42.google.com ([209.85.218.42]:33046 "EHLO mail-oi0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754545AbbDXFdc (ORCPT ); Fri, 24 Apr 2015 01:33:32 -0400 Received: by oica37 with SMTP id a37so32478043oic.0 for ; Thu, 23 Apr 2015 22:33:32 -0700 (PDT) X-Received: by 10.202.200.209 with SMTP id y200mr5385883oif.20.1429853612198; Thu, 23 Apr 2015 22:33:32 -0700 (PDT) Received: from localhost ([167.160.116.36]) by mx.google.com with ESMTPSA id w72sm6073986oie.28.2015.04.23.22.33.28 (version=TLSv1 cipher=RC4-SHA bits=128/128); Thu, 23 Apr 2015 22:33:31 -0700 (PDT) From: shannon.zhao@linaro.org To: stable@vger.kernel.org Cc: jslaby@suse.cz, christoffer.dall@linaro.org, shannon.zhao@linaro.org, Will Deacon , Marc Zyngier Subject: [PATCH for 3.12.y stable 42/63] KVM: ARM/arm64: avoid returning negative error code as bool Date: Fri, 24 Apr 2015 13:27:40 +0800 Message-Id: <1429853281-6136-43-git-send-email-shannon.zhao@linaro.org> X-Mailer: git-send-email 1.9.5.msysgit.1 In-Reply-To: <1429853281-6136-1-git-send-email-shannon.zhao@linaro.org> References: <1429853281-6136-1-git-send-email-shannon.zhao@linaro.org> Sender: stable-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: stable@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: shannon.zhao@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 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , From: Will Deacon commit 18d457661fb9fa69352822ab98d39331c3d0e571 upstream. 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 Signed-off-by: Shannon Zhao --- 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 24edbde..4dc9256 100644 --- a/arch/arm/kvm/coproc.c +++ b/arch/arm/kvm/coproc.c @@ -621,7 +621,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 5ee99e4..7691b25 100644 --- a/arch/arm64/kvm/sys_regs.c +++ b/arch/arm64/kvm/sys_regs.c @@ -836,7 +836,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);