From patchwork Tue Dec 12 17:02:41 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoffer Dall X-Patchwork-Id: 121573 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp4374722qgn; Tue, 12 Dec 2017 09:02:58 -0800 (PST) X-Google-Smtp-Source: ACJfBosEKuparsr4hhT+BYIC/La8q1VX16xz6WVyZ2aHTwEPruLWrj/liOr6+HRYK6dUp9YyAwP0 X-Received: by 10.99.111.4 with SMTP id k4mr2600073pgc.452.1513098178403; Tue, 12 Dec 2017 09:02:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1513098178; cv=none; d=google.com; s=arc-20160816; b=nYOLSypkQyQLsrdoc0tn6H8QVv0UKl4s0tr0Ch3QIsEB/E7b3QC/lcscmYc2+aqDtn GRY3DJkwjlrZXAuIKQdoF8JbsdOJFaFBKtLWf4bJR+rHhPZ7XQDkb/EXO4PtQwlmVhXm NcsWRIkPS7vmiNep1KM7UH5trHgd+2AHfiu9XaAXHGnwPzZ2A41vnywbOI3MKgiVEUB6 0SSEVg7qN8Qzug17egMaTn4M0WwI/R5Q3f50Ab67Ce+o84qHiBf3owP79UZp99enFakf T/OOcPGxeXp/hYI37c+VhRfsoNbqZLfMPQwx8xoJGhMz+ykezHp4Z60hi14gRhdipKN4 +ieA== 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=BMnnKw0UZAflzYK9v206RY7T2SkMZZUH/HrVm0GlM4AcnMcXS9/8vvZ98nBLrNvptA I3RtHaVQSqvuwdyGo5yDYiD7tV80MsThcDUdXSzikUOHEkPkYiTNBIcS0LtnGcN89uLY 3XPahf2nnsHry0t5H7mV2XoKUoDIVjQCekOJB7g4IZuo8uXHNtgcV65tw+2RtH2YNIe/ iPV1u7x5zSQIXoNJ5aFjc24p1dL4ZVre3o2i+kyyIx81sP9aMMnpigzFg3U2g92MNzlI +ztZSOaGJJjcg0Dd2jIpZUNKDG4/CqY9iTGC4nv4n4DF8c9n5CFX8nW6GYUsPSbOAyzT kRaA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=B1lySqpH; 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 o3si8744072pgv.237.2017.12.12.09.02.58; Tue, 12 Dec 2017 09:02:58 -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=B1lySqpH; 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 S1752007AbdLLRCy (ORCPT + 10 others); Tue, 12 Dec 2017 12:02:54 -0500 Received: from mail-wm0-f67.google.com ([74.125.82.67]:44471 "EHLO mail-wm0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752077AbdLLRCx (ORCPT ); Tue, 12 Dec 2017 12:02:53 -0500 Received: by mail-wm0-f67.google.com with SMTP id t8so46383wmc.3 for ; Tue, 12 Dec 2017 09:02:52 -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=B1lySqpHNdrUz5riTogR5R9AoiQuW5HaZgSU2hz8dNrcbEu/CpnTEnRk2yzEk5sf7p 2Etut/Sbn7dj1Mxd3TtEYEqtQHFhzTlGtIG/PaTAa2cHjWf+SwS/uP2DPWDOaq196PoP bNwq0SL9D7Q4m/ASBiCNagR0v435etL//XMpA= 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=BnnJTGQW9eY93i8QdIQRbFeYQHsXFwKtkNVHQ4CglI8+5A7JQOhVSoDuUPN6D21G2Q la8v8XXT7qC5Q3mdWuemWMNwk5onOtaAGVCjpvDhgK3LZFY2bIgvvSrUVfJtUVe7I2Tn oDbWSLWa0DPvO0Os7/paPWs5bkLWVF4muqM3xRbKrhrxhY0GBq5HLsc02bf44OyV90ak r3bSblARFTEfwEn1iar1jSsYY9BwLn1StPKFgi7xAJ0R+Z4E/yZl/XzCXvZ9e9mUQHZV YuR/iN7QLrz+2UVG2gNPAG5W8kQg2UE0kY5r31G35qCOE8hRJB+BWU5uPaEfvdI9ruRy nL2Q== X-Gm-Message-State: AKGB3mJSMdg5km+fkSmSERKcfjSxoWpl58DkV08ocCoylI1UXz/hESXS W+z9LpJO8FZwCQUVSFUWUXsL1AsoWtA= X-Received: by 10.80.219.69 with SMTP id b5mr3772299edl.218.1513098171443; Tue, 12 Dec 2017 09:02:51 -0800 (PST) Received: from localhost.localdomain (x50d2404e.cust.hiper.dk. [80.210.64.78]) by smtp.gmail.com with ESMTPSA id j3sm2003edh.55.2017.12.12.09.02.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 12 Dec 2017 09:02:50 -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: Tue, 12 Dec 2017 18:02:41 +0100 Message-Id: <20171212170241.15430-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)