From patchwork Thu Dec 14 21:04:22 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoffer Dall X-Patchwork-Id: 122026 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp7324004qgn; Thu, 14 Dec 2017 13:04:44 -0800 (PST) X-Google-Smtp-Source: ACJfBosx4Q9AY/uZlnnq1i84E+kwqfYb6QGCUSAbMZATt2L5X67beTyiajLf+hlFI4iLf2tGesxE X-Received: by 10.99.163.71 with SMTP id v7mr9719895pgn.5.1513285484415; Thu, 14 Dec 2017 13:04:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1513285484; cv=none; d=google.com; s=arc-20160816; b=vHEO+uFjto/Tkjif/DhT5h9BkbzJjn/qToeCFJrWmv0h0V6EO+s4/KX2Ook91vH6yu 1++u2mX3E50yQebf59UDSREvtFhBc++mya8LZGfjKs81YvR6xC1B4dTKvYTi3gkJ5Rcj e0XrHhaejoosCl45ypb+9a27uo4qzUa6ttiy/8MjKACAxda5+vWKdco+fPyMCZZqyGjG o80qq9BD+iSTGOAh6x55rCnJ4Hb+zcKEO7ibLIeZdpiTtxMW+x6zmFvMPbxeAfvnwua2 HdYEJCIzK6S1pDyk1s8vmLLM/9MRAI8+E4URTgHb6DP94e9NHOu/rQdbAYoOSiGdtrjp 6X1g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=xF/ollnKfyh9vR4+3dkgc2PrdD5yVTxK9SQgwGsTw5w=; b=1BvHWY+HYAv45p61iVlTeloKpuhjjDYSgCHriOeJ8Vv3No9nX0akvmWoV/SFQqBaDT GWEVjyuRAMX10g1A4dzHDc36ZBVUnbUCfv1FolPQvbQw02swerEjYGvu6/OPcQ+PsRef LHONziB5NxjNOdvUQVq6yxgoHTvlC1cFEFdFxY5Dp03fzYZNqx9+1pAlwdCPnteD4Md6 nOu7pr3cP8GYw1byvg2b+difQFX89o6PbVO53WiTHcO/qXjPPUxDOAMjLh3YX3eNy1mV 8l+Ns1aNqYjoXRs9FWDYwdDmM63BQWnvv4JIJpWtUAvl/GayiiP9ggaty0D/rn0HLhJ4 9A8A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=E92Ywl4l; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w10si3391449pgr.259.2017.12.14.13.04.44; Thu, 14 Dec 2017 13:04:44 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=E92Ywl4l; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752718AbdLNVEn (ORCPT + 10 others); Thu, 14 Dec 2017 16:04:43 -0500 Received: from mail-wm0-f67.google.com ([74.125.82.67]:42909 "EHLO mail-wm0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752508AbdLNVEn (ORCPT ); Thu, 14 Dec 2017 16:04:43 -0500 Received: by mail-wm0-f67.google.com with SMTP id b199so13954531wme.1 for ; Thu, 14 Dec 2017 13:04:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=xF/ollnKfyh9vR4+3dkgc2PrdD5yVTxK9SQgwGsTw5w=; b=E92Ywl4lCfTZI6faDnUMILtb1LTya4Mhuuj7TT7PXx41onoCrH/cMBlcSag5XqbN6w 4rCcLLvk+kidIRKQZAyDmMfMLtO65OXugRc8GTrcDxf+5Zc5jdR6cHrO1BOwI6UhCS4O 0YefrQISTks02Hp9DiKbgHRivYPj4h/U31vIc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=xF/ollnKfyh9vR4+3dkgc2PrdD5yVTxK9SQgwGsTw5w=; b=mmRFJqMDWu6gmAtp0KnmZMTVbquPYJD4KwPAv9krdUQ0bJ/HCYMi0nRKH6TgtItJ8v qS6NZvsVesEyD/xE2PW2fgtg+CYWBjSIQp4oHZCpy8wrpbyqYfvEnEf/eykWwER+n89j tZesvh0Ygt2+4x5649RLabmBo+kgJRfANcr3M+NcnSGcmR5pYfCbWFYtv5BbQk1QclqR 3KLy9HH7vbEqw/iTbXSd6RxZVgLQbAp7sHtktWtW4I4qyn8oI6z7vAbmelcwep4vbM5w pA4DzNiZ4zEO91wUnjA+iRiCZrjN+Dk+nx9fSZgBBrz6LR8o9e3oAMPMTE+ITf14NW/Z 25mg== X-Gm-Message-State: AKGB3mKxHrVWO7iRRDCh6fzQs12C21Yrv0uumOg/j59aGe2l70xIc2RY yxPx8IX4/eEBv4xaCuBprOydYKBe3qw= X-Received: by 10.80.146.207 with SMTP id l15mr14149638eda.194.1513285481539; Thu, 14 Dec 2017 13:04:41 -0800 (PST) Received: from localhost.localdomain (x50d2404e.cust.hiper.dk. [80.210.64.78]) by smtp.gmail.com with ESMTPSA id f11sm4339507edf.28.2017.12.14.13.04.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 14 Dec 2017 13:04:40 -0800 (PST) From: Christoffer Dall To: Cc: Marc Zyngier , gregkh@linuxfoundation.org, Christoffer Dall Subject: [PATCH v3.18 backport] arm: KVM: Fix VTTBR_BADDR_MASK BUG_ON off-by-one Date: Thu, 14 Dec 2017 22:04:22 +0100 Message-Id: <20171214210424.25740-2-christoffer.dall@linaro.org> X-Mailer: git-send-email 2.14.2 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Marc Zyngier Commit 5553b142be11e794ebc0805950b2e8313f93d718 upstream. VTTBR_BADDR_MASK is used to sanity check the size and alignment of the VTTBR address. It seems to currently be off by one, thereby only allowing up to 39-bit addresses (instead of 40-bit) and also insufficiently checking the alignment. This patch fixes it. This patch is the 32bit pendent of Kristina's arm64 fix, and she deserves the actual kudos for pinpointing that one. Fixes: f7ed45be3ba52 ("KVM: ARM: World-switch implementation") Cc: # 3.9 Reported-by: Kristina Martsenko Reviewed-by: Christoffer Dall Signed-off-by: Marc Zyngier Signed-off-by: Christoffer Dall --- arch/arm/include/asm/kvm_arm.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) -- 2.14.2 diff --git a/arch/arm/include/asm/kvm_arm.h b/arch/arm/include/asm/kvm_arm.h index 816db0bf2dd8..46b336df4ec1 100644 --- a/arch/arm/include/asm/kvm_arm.h +++ b/arch/arm/include/asm/kvm_arm.h @@ -161,8 +161,7 @@ #else #define VTTBR_X (5 - KVM_T0SZ) #endif -#define VTTBR_BADDR_SHIFT (VTTBR_X - 1) -#define VTTBR_BADDR_MASK (((1LLU << (40 - VTTBR_X)) - 1) << VTTBR_BADDR_SHIFT) +#define VTTBR_BADDR_MASK (((1LLU << (40 - VTTBR_X)) - 1) << VTTBR_X) #define VTTBR_VMID_SHIFT (48LLU) #define VTTBR_VMID_MASK (0xffLLU << VTTBR_VMID_SHIFT)