From patchwork Thu Dec 14 21:04:21 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoffer Dall X-Patchwork-Id: 122025 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp7323976qgn; Thu, 14 Dec 2017 13:04:42 -0800 (PST) X-Google-Smtp-Source: ACJfBotTlLW8jCMF0Tu2eQ0h4GcsREzOD7U3WZptFtPZaoENmOU5CHP1oWG/UWVArrCBSC2oMh3m X-Received: by 10.84.210.66 with SMTP id z60mr10898778plh.359.1513285482845; Thu, 14 Dec 2017 13:04:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1513285482; cv=none; d=google.com; s=arc-20160816; b=n5HI9/XBihGgazZQRS/KcDIP8hfDJjfqCLwlEPncojJMLnK932zW/9KYLItVFb2JBQ 38vjkIu4oRiv2Waq30VQKNc1nBMetbd3v2Z2WCKHtQLrElpXKoICQKEjBwtRnjj78MjX dNOvQoNF2ZwJ+skYZVcJpOXF7L0MP5D06qtjCRpGIKleLdWUY8Dio2z/HcXyEHkhfi7N StlrulYZvpKaOk8w033K8Jq0vYLO/TuaEM3oa7ZfvLAiT/HK0PTEOrngWL9C7oaiChA+ Ud5aSNmp49zzucfmUgRwyYsDU7mbLNa4rfY+CLSP7StY7SbLrpV5J2oqKvwxPrPFPLDP yFvg== 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=Tbq5NBdZeoeMEXsSAQbt/H/vp03HdkKm8+wy3jZYK7igQPoLxpzh1IgKECMtcrCK5w pVZQfhy/EfMKID9idHBjI8D9PZsNLeu46ICXO18JKKoGCnVWQs61AzfkcxIKXWOf/aFW xciDX8OTUqtMR9DrCYo56WRpY6PWTmjCr/QtKL9VpIlsjiT9ZKiGn0xGaOg/nnW20jG0 IKHYAMCYAd2DKTQ4pTFizpKIG8PdnrRH+Ne447TxfNerUZ1eSIsR/JiBrpUNacy77edT qPJu4SH1Lc41ksdN1/clDlHBF3cCaAm6mDV0Q6zzsrEWtweiGTEHk1qrzN2Sw4RLnS4z jTNQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=POEu2sle; 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 w10si3391449pgr.259.2017.12.14.13.04.42; Thu, 14 Dec 2017 13:04:42 -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=POEu2sle; 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 S1752624AbdLNVEm (ORCPT + 10 others); Thu, 14 Dec 2017 16:04:42 -0500 Received: from mail-wm0-f65.google.com ([74.125.82.65]:37209 "EHLO mail-wm0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752508AbdLNVEl (ORCPT ); Thu, 14 Dec 2017 16:04:41 -0500 Received: by mail-wm0-f65.google.com with SMTP id f140so13916703wmd.2 for ; Thu, 14 Dec 2017 13:04:41 -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=POEu2sle0VtbKL4wfIQZDZA0gWKwEAznCqkm7Ito0DOoukAp7KT7iFU8LddFV2GwFL 4t5zTA9sAmov3yVLemo6O9/JUkCOo9SDlZ937HxJx4NHPkdGvknhaSBTYxN9SvDLq7W+ u5yC4+gMxEwfclsQadvUOZAUKzMMBygLlh7aY= 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=CfYNU1Waum82zeCxi8QnYob7fyKKL/l1TrEK1RiqZM4Gv6hUHMyap0VSE5SU8ILsiG wIdOje6v7w8LQR7n1wznbtQo8E06Xd6CN5MUOd5kQDHbJaNyqW2I2OtY3FOl5AX+GBQX kt69u4wNfzhbgs0wQwZRUnSF57GiDeVjozyoYF/Vrp+Nztvr7n99DtoeLyGviWJZgVXL NcZpPPlB23muSe+Q8MsM65mF9TdfsExCN4rqixNVR2VeakBJB2uK/gbyVAK6zFnhsrYC 8Z7lUdZM1BWRIpL5YWsBjC80jvUXAGk5ogmpZjNekwRh6pZjxMCT5WZWeFV3+HB+6bWY KXYw== X-Gm-Message-State: AKGB3mKq1uXoJJOMrHXlxIEp5NhcHi05WOzZ7g09hh7y7PO00aEHUaJu K6Z3iOzqIVBzFzS4le/UFbPvm2s2itY= X-Received: by 10.80.148.10 with SMTP id p10mr14238363eda.250.1513285480134; Thu, 14 Dec 2017 13:04:40 -0800 (PST) Received: from localhost.localdomain (x50d2404e.cust.hiper.dk. [80.210.64.78]) by smtp.gmail.com with ESMTPSA id f11sm4339507edf.28.2017.12.14.13.04.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 14 Dec 2017 13:04:38 -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: Thu, 14 Dec 2017 22:04:21 +0100 Message-Id: <20171214210424.25740-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)