From patchwork Tue Dec 12 17:02:40 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoffer Dall X-Patchwork-Id: 121572 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp4374711qgn; Tue, 12 Dec 2017 09:02:58 -0800 (PST) X-Google-Smtp-Source: ACJfBoveVjvqD09PUr/AGqt3SNarfM3AvueYPx0gN4hVi0ImgoW7fi/qKQZUN+hs6GeTqGJ6CSaq X-Received: by 10.159.202.150 with SMTP id p22mr2949778plo.128.1513098178105; 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=kN2TUgNe7T9V1Iyg69A3N487vvYNDt+Jd0eV5RivhBS4mlOkr0vqB47+Cq9fPRdB0e /ZYQfloeI9zpao4mwgLn44sYgE8xCP8AB9d6nJOxf35TFSKQstv8JIo8JlhZQec6ChFm 4vFAqt/DVUIeIIO7szs6/qz9nUY3acEk6+EpmCsgCHi7ESDP47ycR+FftO3kf2IQHEU9 rqr1seDxUmKvfA+ZopLsBvQE7q36XrGGY+hLAZB/fwKvF6gQgq5xwdq1rkjnGtOnPj0S rP2CYLA6TTUXICa3J6z2ARLJXJ97iWmcjY090uDexZP+SU8CNSa+7yRZpwfDKzRQEyLk 1EOA== 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=8xE6D5IOICQCNzzdFXmDtGewrRmJCUvODOTjIpzLK6U=; b=fg/sVHishfVJqcMHRp2fImR+t5+845/sVr2kIpUJkkE6KTp/aXO0C15BJnZIZPpByQ IFJWCdDc4S5mWvtVXeqCZ44WC7+sCLCWNXHzVIBPEMPRGKovBGGKQpGxbnPg+jg4Svhy hhfkfDbpw5cIPG839nyiz88yQlQLMVwfZjbusoYnfkUrEPqbYgbzfqG9S8g9X5VUMfRF 2Rc8RnH0MG5wYne00u7r2CbwtWecrX6Thrl+iEctPAHBEEJddpItfbllbQOe/OhDorxX AJ23iAyi7AGn/MFLZ44yFAyJoQ55r0UG6BURqR4HZtqnucOeKRuatOL217WQhytSJL0r 6U6A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Nu+mRDdH; 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.57; 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=Nu+mRDdH; 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 S1752111AbdLLRCx (ORCPT + 10 others); Tue, 12 Dec 2017 12:02:53 -0500 Received: from mail-wm0-f68.google.com ([74.125.82.68]:46406 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751625AbdLLRCv (ORCPT ); Tue, 12 Dec 2017 12:02:51 -0500 Received: by mail-wm0-f68.google.com with SMTP id r78so18846wme.5 for ; Tue, 12 Dec 2017 09:02:50 -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=8xE6D5IOICQCNzzdFXmDtGewrRmJCUvODOTjIpzLK6U=; b=Nu+mRDdH5yGpg9sFhlflsC2yLAyMgkDy8hcp04eN+udHMMZJzciDvVXX8B4DJUejF4 Ktwd7SWWCOG7IICOFDs0ny6tiQ+U4TRGS2ida6JLTvy38KbyPqN+VOIqoMSYXw/ANQ57 /zwbGnM0FcdksGrqveMcp8XXQPOgIS9ewx/hk= 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=8xE6D5IOICQCNzzdFXmDtGewrRmJCUvODOTjIpzLK6U=; b=hdf2yRwlhFN3VmbhIR/NeBVb2J/VAFJqJcjJI/2vjJFmlfWeBpxnzSELrFRDq4EfS9 NY/ynjBy3yqWTEIsmmD641CXQeVZ/k+gFt0/op4U+oE1V9mnm5BpFdoPfXRaKki/g6pm rs8kgrZiV3ruhHuzYTeLffJfl1i3Ih0b+6/zMiz1k2nFYtExZNEaQH1VN/YnkmTmJad3 AzyG9KfJGo96nE1Qxm9hwJvp83FQWTBXBbKyqE9IION3gOwugK5mfNzUz9GQcVwj6Vfm /FaOMoJLZJg3/wZfZmh7n4HwnqpOFoDqC7n4SkZXjoP/IhZ1Zqq3bGVBoRCB0x1UDqjC +jNA== X-Gm-Message-State: AKGB3mJQY8B/gj2HSqJTngCeVO2yME2P/NPNlXmbtICAL6r4jYx5ehGX bgv+W4sfb8lkExnir4ls+IMACZ6AFCk= X-Received: by 10.80.148.53 with SMTP id p50mr3690877eda.135.1513098169941; Tue, 12 Dec 2017 09:02:49 -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.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 12 Dec 2017 09:02:46 -0800 (PST) From: Christoffer Dall To: Cc: Marc Zyngier , gregkh@linuxfoundation.org, Christoffer Dall Subject: [PATCH v4.4 backport] arm: KVM: Fix VTTBR_BADDR_MASK BUG_ON off-by-one Date: Tue, 12 Dec 2017 18:02:40 +0100 Message-Id: <20171212170241.15430-1-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 dc641ddf0784..0f2720713492 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)