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: 10090523 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 086C66056E for ; Mon, 4 Dec 2017 14:34:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E515828D39 for ; Mon, 4 Dec 2017 14:33:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D88D028D3E; Mon, 4 Dec 2017 14:33:59 +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=-2.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, RCVD_IN_DNSWL_MED, URIBL_DBL_ABUSE_SPAM autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 5B3C628D39 for ; Mon, 4 Dec 2017 14:33:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=N/+f7fidmi7uLu/0+WpoC/g8XjqU4pXOY8tYslcbdAc=; b=B+zx7HZQZv6UoYvsO7eMfrj1Qe hdqG0AA9BRMc2aiE6fPsgUCGOlO7sy45lzm0rNCAUbauB+ZB9dEcPCzrzp+ngG+TIIp0p8+7Wr8VV ihkkq2EhI4wotlluiMUMnymBgJnW19A5zefpdQIV6Dm0kM9snFq3wlX2pp8aKouAUXOOsCUkeDeNs z19Wkb/3+Z35XDpZBz4xSJBaqVNskwE0MlJ7K3wllNrUdCH++O27CPlcrdXT0PWWapUVVu39Az2Bi buWIAEnwobfPE5MfbpJubb1YD2O+d2lepBbFGs0wIYYndUrWqPRUzyo+o4ug4tEONpJb7tdrSybrj yer8S6tA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1eLroc-00058y-UK; Mon, 04 Dec 2017 14:33:50 +0000 Received: from mail-wm0-x242.google.com ([2a00:1450:400c:c09::242]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1eLrM0-0002O4-62 for linux-arm-kernel@lists.infradead.org; Mon, 04 Dec 2017 14:04:21 +0000 Received: by mail-wm0-x242.google.com with SMTP id g130so14811810wme.0 for ; Mon, 04 Dec 2017 06:04:01 -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=CWq/m86UIQO1CUIKJ0s4SEosltPKxH1iEwseJlccrU59wqI/AzqW5yd7xBO4UOYn4+ 1hKUsJVEAZSCskKcU3uizPiZyG/1daT7ARdKItE7/R8XlGxt8PAzYriTfBvaRooIe97w qcCPyFm+JueGgY8pyrC82iPLGjPAF1OjyKNoWmE+lZ6yZCjEmwAr6cOPyMxl6gFJbLII aB0ukTFZ6sVQiD5NFdSUdJOnH2NgB9mjkGqtFqC9hh0h5KcAXxYQtAV0QB0MlxRflQ7+ 0acjzA4uZhJLDPq+nJMETyx8iPlbcuOrF3x5xLc5enTXa9Nn8Yh0/dHFTxYbaQHvvAvD WlGQ== X-Gm-Message-State: AKGB3mLsQciU3yAigOHHRT2lYs/BLW4v9lPXMzytwsCPpdttCQ4lK4gq ZrOOFicSK9V2pS2zXHkTjjEsnQ== 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?= 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> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20171204_060416_394287_ABB16F7A X-CRM114-Status: UNSURE ( 9.34 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Marc Zyngier , stable@vger.kernel.org, Christoffer Dall , kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.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)