From patchwork Mon Dec 4 14:03:38 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoffer Dall X-Patchwork-Id: 120540 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp4472574qgn; Mon, 4 Dec 2017 06:04:05 -0800 (PST) X-Google-Smtp-Source: AGs4zMYiu/7QjTwNlb9d6r8xwsvWHO3YfHZZNiY2cHWhqAT60Y7n6RV2OcpJYa2YoMrK8nNGinwW X-Received: by 10.159.254.4 with SMTP id r4mr14788930pls.11.1512396245007; Mon, 04 Dec 2017 06:04:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1512396245; cv=none; d=google.com; s=arc-20160816; b=Jl2t6F3d/4piBbML8sc096XWzKpBAGDhDy3uB/hHbKsuy4IGoMVAUxK/S91g+u8Yi2 7xBrGzUEzR0Le6ZuoWukOIVCKIgqZQgbcY1DpbgwAvKAVAt0//wYYBjY2tJorT65QQiq ILZ+vphzXCNW2Hn0bss2IvUuCiHg2I0k7UnRf6VyFo3+1KLlNkuPN8Xn9e5He0xl/vaP BH2v1kzViD2IGKJ6rmn2VwOTOiNh0eSfWmRrESaHNqN1ScnRuxVq+RnPiZ4POWHvdNfY pbQ8WklrHyoWtJ4S76pHbYaZHr5Uj2xZnty67qA6YyHxLAD8buI+AEIPVo94fJP6QDTC lNhg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=i0A8EIVQZD/efppbWzjU9hdsLfOIgzRvACs8OxFpE4w=; b=Mv/6wJyaz0gIFUWqiQdCOZFRwkceXTpXpUMmRlwyqUjNGj5WkpnyGGtzUBRdAjqXp5 C/OmRVuYwzPj3/CwjRpmirur7rxDJUK8U36Kbw1ifqh6Po1t952t7EdiCQ1KekckU4GH TawgDFEwt35aYG8pKoZA7FVQAxGCG5xID0ivl/sXLTqiXl9RkOafIbZrLAmNf4HEs8ie 8C6ER8+n2Yr43u6Nn68Pmm2g5Re0C0KeI+BA6OurBC6EwR5J7XOraLP4rLekIJWQ4giM ykw47aCu/Br4p4vrj+dEvKq2Yh7MRRap/E5N0hNdDqEC2TVWYJlsR+5zFavvImZFUTnB 4q3w== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@christofferdall-dk.20150623.gappssmtp.com header.s=20150623 header.b=sAeljr+h; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g31si5138782pld.67.2017.12.04.06.04.04; Mon, 04 Dec 2017 06:04:04 -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=fail header.i=@christofferdall-dk.20150623.gappssmtp.com header.s=20150623 header.b=sAeljr+h; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754248AbdLDOED (ORCPT + 9 others); Mon, 4 Dec 2017 09:04:03 -0500 Received: from mail-wm0-f66.google.com ([74.125.82.66]:34533 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754448AbdLDOEA (ORCPT ); Mon, 4 Dec 2017 09:04:00 -0500 Received: by mail-wm0-f66.google.com with SMTP id y82so14751883wmg.1 for ; Mon, 04 Dec 2017 06:04:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=christofferdall-dk.20150623.gappssmtp.com; s=20150623; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=i0A8EIVQZD/efppbWzjU9hdsLfOIgzRvACs8OxFpE4w=; b=sAeljr+hNU0HjoZZhbeZcj8c3PG9syUjCK+EJw0dJn/tIddoulsfmhikdPaxjB6jUw eEoczVrcXZNf1WgoMlE4QIPqOOaWUgqaYgBSt5eOvTrZS/MZHonOJX248nPCAkZBnLIs vcR5CU6M45i5lOpVPwTR4RwH72aDtiybj0baihfqVU8VB8i9jmzisdyVoTiALReDffnG IqVkp2DcKN0iVV6LolWg1WdEJTnyA3p6jPyxamDnKQQJnLPi/RIgoQ6p8wP52+SDE5ap xyerEci6hPzGgOLdsj7iSh3y3DirEZvMDiuLcyKKpqHu72JYyRCI0oF35peAqVfPn4o/ 5FeA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=i0A8EIVQZD/efppbWzjU9hdsLfOIgzRvACs8OxFpE4w=; b=Q0Au9j++kfZaX66xAljmaZ3lEACOy2T0MCI7YpQoO6qbeSdKC2jGHgDpxkE0WMKALc Xzq9FsbjpVVC6IFD/CNgwvSaVtcQGAj9FsInKulQ4dlVNdHW6OU7n/tv2W/rZDeeZIOm UvwdXzxrq3/09AGMZBA845y4z11WbxdGebROkKh2Ww82sL9Xzna5mcWcsnqGu1gCkFDT 5nLAbk2ySlC5GWkoEuJdzeablfXUy6ed1mEn+HpYQcr7l4qOI6cCAwkzd+eGaI6tvxS0 4uO+jg01d61ZFqNgI4znsUgsrRPCJ6VQ83adLDqEl9rRBby4xDAgv39PhJ1wqBEKU7sa au6g== X-Gm-Message-State: AKGB3mI7OTUFK8Sm5niX68JtTrUcc75dtb7ZzhtlsaYp0dHH0b7DpksQ YUp3XpEBglUd2N6Ymx7xB91KDw== X-Received: by 10.28.193.139 with SMTP id r133mr3419031wmf.39.1512396239729; Mon, 04 Dec 2017 06:03:59 -0800 (PST) Received: from localhost.localdomain (x50d2404e.cust.hiper.dk. [80.210.64.78]) by smtp.gmail.com with ESMTPSA id g7sm22794279wra.38.2017.12.04.06.03.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 04 Dec 2017 06:03:58 -0800 (PST) From: Christoffer Dall To: kvmarm@lists.cs.columbia.edu, Paolo Bonzini , =?utf-8?b?UmFkaW0gS3LEjW3DocWZ?= Cc: linux-arm-kernel@lists.infradead.org, kvm@vger.kernel.org, Marc Zyngier , stable@vger.kernel.org, Christoffer Dall Subject: [PULL 09/19] arm: KVM: Fix VTTBR_BADDR_MASK BUG_ON off-by-one Date: Mon, 4 Dec 2017 15:03:38 +0100 Message-Id: <20171204140348.21965-7-cdall@kernel.org> X-Mailer: git-send-email 2.14.2 In-Reply-To: <20171204135637.21620-1-cdall@kernel.org> References: <20171204135637.21620-1-cdall@kernel.org> Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Marc Zyngier 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 c8781450905b..3ab8b3781bfe 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 (((_AC(1, ULL) << (40 - VTTBR_X)) - 1) << VTTBR_BADDR_SHIFT) +#define VTTBR_BADDR_MASK (((_AC(1, ULL) << (40 - VTTBR_X)) - 1) << VTTBR_X) #define VTTBR_VMID_SHIFT _AC(48, ULL) #define VTTBR_VMID_MASK(size) (_AT(u64, (1 << size) - 1) << VTTBR_VMID_SHIFT)