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: 10090335 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 1251B60329 for ; Mon, 4 Dec 2017 14:04:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0DFAB287DE for ; Mon, 4 Dec 2017 14:04:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0266B28D1D; Mon, 4 Dec 2017 14:04:05 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID,URIBL_DBL_ABUSE_SPAM autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9F290287DE for ; Mon, 4 Dec 2017 14:04:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754457AbdLDOEE (ORCPT ); Mon, 4 Dec 2017 09:04:04 -0500 Received: from mail-wm0-f66.google.com ([74.125.82.66]:42636 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754447AbdLDOEA (ORCPT ); Mon, 4 Dec 2017 09:04:00 -0500 Received: by mail-wm0-f66.google.com with SMTP id l141so6006486wmg.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=jk7eSGF/J9+1rV6/XYdLLp2Jwhs85Q70DRZNn2CJz6yBqgjCOI2lgukMNgnXv9Qeux u1sveditrvXRz4Y9wZMoFnPjm4wl4nfZY8bX4wXSvyZfu1Xo0ZtsjUDQBe5JrhNcRM2M KlzDji71ggt0tYt3wSLytVn1IZQ2FpcpdsoCY2VE1H89u6c7vo+3grkAtrbiIOVxxmKx G13FwUJypTgvflqKEtEzZTXjtoEV+djFiRz2r4FmWaJT1t+Hhin+UiUILADInXM6OkoZ Rp8V2GZH7AmkGQyKMGdiBZdre8K6cqoJtTEGFrhFucrJrfmZ31sH/ZUSlAMpi7PWhgDS pmcg== X-Gm-Message-State: AKGB3mJT3R0on1jph0Gf+bWMW1+sy+9WIz5AVN+KFGhtAtFBFX6bu2FU VHkZuj4ZmSANFSE6Ub9X3HBd5w== X-Google-Smtp-Source: AGs4zMY+3Q7APJyt8pF8Z+n2LnTQDfDL/JBB7j32uMjMtVVpXmxzc9UwXjyHJgWgVgCB5bljNdeCbA== 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?q?Radim=20Kr=C4=8Dm=C3=A1=C5=99?= 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: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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(-) 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)