From patchwork Mon Dec 4 14:03:32 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoffer Dall X-Patchwork-Id: 120537 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp4472377qgn; Mon, 4 Dec 2017 06:03:57 -0800 (PST) X-Google-Smtp-Source: AGs4zMZV3jM5yNR1z6ACt3ZB9l3ULFJtfH0x4NqCPvyn57/TXtiPxLEGWuet27x7epGGEhar3fz7 X-Received: by 10.159.241.134 with SMTP id s6mr1991178plr.354.1512396237147; Mon, 04 Dec 2017 06:03:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1512396237; cv=none; d=google.com; s=arc-20160816; b=0aPZlnjoF5r/gBKD+RnnsdAQDzUG4GfjXlsvEK6mAVW8xSjfxlZQYYI4bSafKucM4O OUoBVGK6ossikAjA8GjZio7zky83flRhFNgsyQfUMw5EbSbCCh90lJj7nL+PopGpJBzq /av1rzvnXVOiSDhtnf1iCYpbpOV+Zcjap3lyChSnUHiJCoiYfMK+qhS7FbrafVESJ9/y Xa9cmXiorVtNeJz+WEp+ZJYnIzsxheiV+qCWWi7/khf/4mhEBNSjzZYCx+k5AAXYLbvS PV8UlaCwSXB0p0G1pKq0acP6kIdGZOai18yjF7huW/J41aOf7vHqonmxE/kFAnxS5K+B svng== 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=NZDL88KYHnHG1dfr5GLAsbmFC9VITmxGpkIX79zI0x4=; b=VjtvJ4X/A8RnA0IR1HN7x8Nmmx0mBcgyTv0B0T/inYadLOrMyQdTgCbGluJwo0YRcq FkGOQ86eP82OdMWm1ugn3emZjmorOg96CzFnUDz2Jr1Go6s3b1sDWyvofD+gjRDgUdFg OmPTxAOEe61/3uTo+VSi3CfZkerQKQNq1erL/mDvxAtt9azCCEZKC1vvAbbXE4Z8CihW rGGy0tTNVRXKuplVH7Qg8nTQ4S6rO0mQNcllLVyuFSimsi0eYKwSDEFui6dluqp/l/rU JuJp193nU0h8lLndXyEA/aU5jBsAtWJz/PIo3WsZ6jpobOWjTIdics3hhPWUcYCzv3QF 9pnQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@christofferdall-dk.20150623.gappssmtp.com header.s=20150623 header.b=wGghl2RC; 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.03.56; Mon, 04 Dec 2017 06:03:57 -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=wGghl2RC; 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 S1754193AbdLDODx (ORCPT + 9 others); Mon, 4 Dec 2017 09:03:53 -0500 Received: from mail-wr0-f195.google.com ([209.85.128.195]:40816 "EHLO mail-wr0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752316AbdLDODw (ORCPT ); Mon, 4 Dec 2017 09:03:52 -0500 Received: by mail-wr0-f195.google.com with SMTP id q9so17406094wre.7 for ; Mon, 04 Dec 2017 06:03:52 -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=NZDL88KYHnHG1dfr5GLAsbmFC9VITmxGpkIX79zI0x4=; b=wGghl2RCdItdCHp5ICrZPtOZ3lUZ8p0ELOFkrrv6VneDnjOYC1YdLYvMBtvSee7EhQ 5n4Jpq/t7Vr2kI6KoWOpumQ8zCENDoUSYhJQtetti5/B1/+scZnbe4UhTqbhLzq67Tr0 rSoOLRNMLZyK7BuvySPoPo1kku3kVpRAOyGcLLyw5wKVFv7C8Psj7RJSdTHHIsbK82PS dX26i5GwFsLImZENf3Ls8r/6j0NQOgSCKmN+bwxrX9stnxmmXlnJyvIjxAko7bFR8e8H rjQ3ZPt++7+0txMwtyxffsZYJNgqcDlBerVJRGM3/KmInZ//6ifAOBMzZKEPsEMWBV/X MAdg== 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=NZDL88KYHnHG1dfr5GLAsbmFC9VITmxGpkIX79zI0x4=; b=YyETu1fnyOawtBrl/Gxe9GJfRntxDpnuI0pv7PSoTAsA9CzBIL0b8W3W2JOd0ZilDR GHdSzinOQAgfYwHffV+ciiI7zgntBarJaAqOYIFYlnP41hTVVnMSNSmvJvG+IG8pMeqN LmFguonbF2WHLhO+Q/VSwTgWRQ3W5FoAPwnAw7wu4vZQrtFIoDNqB19IQQn9CwQStIJQ 5/thoDZPv81r5DO4miFvPhTDpcbCQRBWy4jAio2eEaMxWuVkP8bonS8X+xWDznN1mD+C vYCW3lfMVdJ9bWXzTzdik5BIWFIYGOi+R2/uPZQGHUr/sUt9F/OWm8aRHjD+yni6BKiG 21dA== X-Gm-Message-State: AJaThX4tEitn75a3hUV04Y7jfgloj+wtu+oo6FEm0ICqHjegILssb5oz jrxAUytx4rlv0tqSqflxSX89uQ== X-Received: by 10.223.150.2 with SMTP id b2mr12486512wra.185.1512396231607; Mon, 04 Dec 2017 06:03:51 -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.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 04 Dec 2017 06:03:50 -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 03/19] KVM: arm/arm64: vgic-irqfd: Fix MSI entry allocation Date: Mon, 4 Dec 2017 15:03:32 +0100 Message-Id: <20171204140348.21965-1-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 Using the size of the structure we're allocating is a good idea and avoids any surprise... In this case, we're happilly confusing kvm_kernel_irq_routing_entry and kvm_irq_routing_entry... Fixes: 95b110ab9a09 ("KVM: arm/arm64: Enable irqchip routing") Cc: # 4.8 Reported-by: AKASHI Takahiro Reviewed-by: Christoffer Dall Signed-off-by: Marc Zyngier Signed-off-by: Christoffer Dall --- virt/kvm/arm/vgic/vgic-irqfd.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) -- 2.14.2 diff --git a/virt/kvm/arm/vgic/vgic-irqfd.c b/virt/kvm/arm/vgic/vgic-irqfd.c index b7baf581611a..99e026d2dade 100644 --- a/virt/kvm/arm/vgic/vgic-irqfd.c +++ b/virt/kvm/arm/vgic/vgic-irqfd.c @@ -112,8 +112,7 @@ int kvm_vgic_setup_default_irq_routing(struct kvm *kvm) u32 nr = dist->nr_spis; int i, ret; - entries = kcalloc(nr, sizeof(struct kvm_kernel_irq_routing_entry), - GFP_KERNEL); + entries = kcalloc(nr, sizeof(*entries), GFP_KERNEL); if (!entries) return -ENOMEM; From patchwork Mon Dec 4 14:03:33 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoffer Dall X-Patchwork-Id: 120538 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp4472403qgn; Mon, 4 Dec 2017 06:03:58 -0800 (PST) X-Google-Smtp-Source: AGs4zMag/ZhnLLep5b6om8O2OwFgA1UViei1Yjy8NVolbiA4fwTKxBI4MBQ6Q9zxQsKjmcQwEqlE X-Received: by 10.99.174.1 with SMTP id q1mr14011402pgf.434.1512396238206; Mon, 04 Dec 2017 06:03:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1512396238; cv=none; d=google.com; s=arc-20160816; b=SgBnLGyJDT50wH4q7mkPH2h6dks98ocnZRzPNghzpPR55zqRY6OO6poP9OPsfLqfOg 3kfofFkPQGlRnIdlnH2DpeN2tfmN5DBXpXwfkKEWoJZ8BhAmRqXocxwbQMYB8gC+USfc H0ciGal7xTPxPe4ZWpfI8EmlSV65VQD1Aaw3UXkfrYYlX7qufM+YPjKMJuG02WZB3XRp jmldnbTMvm4Cv7XU+6PVy6mTUXchp601QnmYrQurLXN3DGxiGVOOjT7w1LASiRwQxmTT qe54EP6MX+mWvmd3rtRZQjnbq5KYa+WoTqZMb6fX3YWPj9y5jD6IkW3W8+UA8l6zHKK9 GZlQ== 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=TmaNMu0M7k204C0NDi+s40IgEK6nif15+A5iZT2a8Jc=; b=jrfVKL1i9Oc5Y6qA2YD+l5eZ5Z3kU43l13mdXdrza7sAew0xlDGSDijFSbeAziVVi0 D1e+qecqMFrWxnOEAeRpzZEAjmIhMGiELmLHB3OvQKV7l45T45bAmpordoD25yMdbQ0y mzopeHdJ6M0h1g/xEl4bQ1tnByqBKWmlo9BKhxNDxKSkIm4aXv9+lZ9i4N638uh5V3RY HcAcsx+vFNZ0olAy8Dp2qNnK/OIL5ZDu5jQb1Dk8cGiU7w9oTRMPvBzOy8YehGDasMwJ aG0tUu+7OsBAJVQz3ddHxWuYKBNFFXvX/qq4qnMQ0E5SgE7Yc0DJkvkQ9/P2ilTLM2dE wLRg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@christofferdall-dk.20150623.gappssmtp.com header.s=20150623 header.b=gqo/phH7; 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.03.58; Mon, 04 Dec 2017 06:03: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=fail header.i=@christofferdall-dk.20150623.gappssmtp.com header.s=20150623 header.b=gqo/phH7; 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 S1754305AbdLDOD5 (ORCPT + 9 others); Mon, 4 Dec 2017 09:03:57 -0500 Received: from mail-wm0-f65.google.com ([74.125.82.65]:37376 "EHLO mail-wm0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754094AbdLDODy (ORCPT ); Mon, 4 Dec 2017 09:03:54 -0500 Received: by mail-wm0-f65.google.com with SMTP id f140so14474032wmd.2 for ; Mon, 04 Dec 2017 06:03:53 -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=TmaNMu0M7k204C0NDi+s40IgEK6nif15+A5iZT2a8Jc=; b=gqo/phH77XEQ6AxcaOPptrlizc0DPPBJZs1/QRrK5d/7p++f/MNZl35eyEG+Uy5k+2 thkRZFXjoakJgXq14hhIbNHGv5465Jkypvanpvm4sC5Ul/cSS92XryoW9Qlt7IErAicv sQsYe9SwJbs+3UDhE03njBVDHf2GXu7x/d7fZjO63jmUFG8EbaHJ/hKbpLoLkQyGtaRx HlSqtupbOmTXpQkuWq++kN8j7hnlmooJ3G8tbUkhqGOjxX+kOxxM0at2qe73bwsSHzge xcL0eG/dDodaMCZdObyJrc7L84tWJ8ttE+uvvAjBVNuPAzoW17akR8/NmhzVMjCd+o4r Vsjw== 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=TmaNMu0M7k204C0NDi+s40IgEK6nif15+A5iZT2a8Jc=; b=V4YxskgPiqH1X6CtDqbrkD2nczpg/T9Mr0KEuOoA8qhu6uMHHGWPylaVnc2pkSHRuk gHoP7ffS/ebRMtQRH2v8SFjLYAP92Xiu9hCD9MMtCCO0weZGIRnt18KtPR2vBVTuTbz9 VdOICF9g6df3TYl69rXeaoypVXzLyemPUUklAp7LMKDHWlIkJO4BklOo+NjuHKC0iw9b GNukuMgmUpm6vkEuJxw9p6WCcBvChBzWcVqC0YZUK12RqRgWoMOeoWuACsf8JGqYOiNc bbG7iIqSEMBe8n8j3HEXXfG8N/qjjQkHDc/p837MBeg1Wk2/tjJ8XGXu8ZnO01iEAYWg cBJA== X-Gm-Message-State: AKGB3mKcWt2tyBT7+rm/6Om0WmjFOJBN73vd365leoBVEtoqLGgv3/Tc RlP+FUxKRMxLF+b2983pqfpqXw== X-Received: by 10.28.66.148 with SMTP id k20mr3507437wmi.40.1512396233015; Mon, 04 Dec 2017 06:03:53 -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.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 04 Dec 2017 06:03:52 -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 04/19] KVM: arm/arm64: vgic: Preserve the revious read from the pending table Date: Mon, 4 Dec 2017 15:03:33 +0100 Message-Id: <20171204140348.21965-2-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 The current pending table parsing code assumes that we keep the previous read of the pending bits, but keep that variable in the current block, making sure it is discarded on each loop. We end-up using whatever is on the stack. Who knows, it might just be the right thing... Fixes: 280771252c1ba ("KVM: arm64: vgic-v3: KVM_DEV_ARM_VGIC_SAVE_PENDING_TABLES") Cc: # 4.12 Reported-by: AKASHI Takahiro Reviewed-by: Christoffer Dall Signed-off-by: Marc Zyngier Signed-off-by: Christoffer Dall --- virt/kvm/arm/vgic/vgic-v3.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.14.2 diff --git a/virt/kvm/arm/vgic/vgic-v3.c b/virt/kvm/arm/vgic/vgic-v3.c index 2f05f732d3fd..f47e8481fa45 100644 --- a/virt/kvm/arm/vgic/vgic-v3.c +++ b/virt/kvm/arm/vgic/vgic-v3.c @@ -327,13 +327,13 @@ int vgic_v3_save_pending_tables(struct kvm *kvm) int last_byte_offset = -1; struct vgic_irq *irq; int ret; + u8 val; list_for_each_entry(irq, &dist->lpi_list_head, lpi_list) { int byte_offset, bit_nr; struct kvm_vcpu *vcpu; gpa_t pendbase, ptr; bool stored; - u8 val; vcpu = irq->target_vcpu; if (!vcpu) From patchwork Mon Dec 4 14:03:34 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoffer Dall X-Patchwork-Id: 120539 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp4472493qgn; Mon, 4 Dec 2017 06:04:01 -0800 (PST) X-Google-Smtp-Source: AGs4zMamaTF15AswoX7pUa1ch5EQ0Yhqq3rrpVg1lStQLYP/N2D2Xp9wEd0C6rroB5rayFsvfMEG X-Received: by 10.99.97.200 with SMTP id v191mr13444343pgb.300.1512396241531; Mon, 04 Dec 2017 06:04:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1512396241; cv=none; d=google.com; s=arc-20160816; b=X6lQSc5AamyyLIeRP0RuzxAKtpxs06VX9jDE85NJEwIWJJ6lC54w8UJDNJqxmdycqs oHGFW7D70UYbzMPOiuQTG7Xb8jm4mJrKXF/RbTYytNyp7quG2jeYa48UdOH+oAT2HIz/ gtItGyepBr9b3ijVxm1jU8RJ+cwCcQVNc03BSl2btQUmE7djBJ3F3kjFHvy0gFkkp+gT J0WyW9z2Kl/e69nK/pwcEDZJQ+SZvGyDfsNYlAhqbtCmTRqcdeuGW0uQ3mHPhcjk1Aar riq/jhE/xWw9DKEp0kIMEqwNqpXCVrwF3kQh1/BDkpkZhYR3DdFRJhYiaQxXrVYOM+xj Vf1g== 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=vvDjbfaM4y+/+S5Wqc95p4E/G7g6+DZ4+sOra8RrMEw=; b=snyUbFFVmH9pytlFZZTpilYXuwVwZQVDmVOr1WHIGFumKDGrRMK51e6lm5AQ4xjw/X +vArw+4RaoTfagp0XODlhd84YEYak7Ci8qOQk4Gh898FtPrxH7AABvpLmZwNTS/hsoUj FlIEB/kqHfY/Tv16pBpc8hkr+G4Inx+yDIxcpJeayKrXSyJtZyVH6m4Xs6diWK19D3Y6 emmS/oa4+AMZwgh87AtyXz5pajNOnPc6jcpUYZqdH+dw3PwgrHlK6r/PYTQTzZAgYYJI M/LNVYmXBZS20AoEXSgjDO3ifDCg9n5WLBdnDX58Xsv12xVshrTwM/FzhSO6VvKS/jpm EUbA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@christofferdall-dk.20150623.gappssmtp.com header.s=20150623 header.b=He9By1ad; 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.01; Mon, 04 Dec 2017 06:04:01 -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=He9By1ad; 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 S1752231AbdLDOEA (ORCPT + 9 others); Mon, 4 Dec 2017 09:04:00 -0500 Received: from mail-wm0-f67.google.com ([74.125.82.67]:46940 "EHLO mail-wm0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753878AbdLDOD4 (ORCPT ); Mon, 4 Dec 2017 09:03:56 -0500 Received: by mail-wm0-f67.google.com with SMTP id r78so6019017wme.5 for ; Mon, 04 Dec 2017 06:03:55 -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=vvDjbfaM4y+/+S5Wqc95p4E/G7g6+DZ4+sOra8RrMEw=; b=He9By1adtmXQ868oH3dYKUprzaeEUXGlKzko/gYLJyX2cWuSEW5p5mxZWUZ5uIxqTs Jl5Fn+mxxwig2+VPutuEdnbyBdACDOmp0ZXmpGpN/snkyRvwcGOG/0+mY53ISpztddzL +/sIa+rG5881znJsrRFjl7Oz/xFH8J7ZyB8j9+/OEkSrBZR56Ypg2PwhefV86lR+WgQ7 v3Dt2gEjAltK+yFXQdgDtHNIeVcL7RHDSdZQ/sr+ZFM1rvSrN4Nw6UOKRsig/KZ5gom7 TyG4KXluQPSVjXV6pYObBQVUgTYjU/slADkmMPu15mOsz34gilfg0KIV9K0cZwr5JYgP 1BPA== 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=vvDjbfaM4y+/+S5Wqc95p4E/G7g6+DZ4+sOra8RrMEw=; b=JjJi59M2/Nvl4PTLRK/hES17NCW9zGG64xCAy2amuduaT8CzMKY7cTDVDFUTicOpUb XGz/f5gNxcOIDdEhqrPwRlN60izDLUjWOxAonPWYH6hOuJKclVyDXoq7FvvdSCG1hdnx fIbi8vCwVkWgnTeBpCsk1oOPYhy94n91wA0SFAu6H+uCsqvjpzJ+Voqi9JMCYxJloYHt vBokNdP7zodrNylGCn30JyMU2ACyuha7KH1V/t0H1bZjtKP/obP8dfEWHLcIN91fFKid 0anEUV5cPWm3TvQ+nUQ+8soYL4Ke2cytqhtt+g2p+7MQJIvCGx/vslwdiqLyicyxhqhl 8l/g== X-Gm-Message-State: AKGB3mJz8Or+TnxYrEmi98Nz83g7Q+5uC7SCjQ+vrlG8vX4s/rh1y4pk 4oW2f1eAmYgjjsCMglj9jNKBZA== X-Received: by 10.28.104.6 with SMTP id d6mr2972448wmc.101.1512396234346; Mon, 04 Dec 2017 06:03:54 -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.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 04 Dec 2017 06:03:53 -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 05/19] KVM: arm/arm64: vgic-its: Preserve the revious read from the pending table Date: Mon, 4 Dec 2017 15:03:34 +0100 Message-Id: <20171204140348.21965-3-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 The current pending table parsing code assumes that we keep the previous read of the pending bits, but keep that variable in the current block, making sure it is discarded on each loop. We end-up using whatever is on the stack. Who knows, it might just be the right thing... Fixes: 33d3bc9556a7d ("KVM: arm64: vgic-its: Read initial LPI pending table") Cc: # 4.8 Reported-by: AKASHI Takahiro Reviewed-by: Christoffer Dall Signed-off-by: Marc Zyngier Signed-off-by: Christoffer Dall --- virt/kvm/arm/vgic/vgic-its.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.14.2 diff --git a/virt/kvm/arm/vgic/vgic-its.c b/virt/kvm/arm/vgic/vgic-its.c index 1f761a9991e7..cb2d0a2dbe5a 100644 --- a/virt/kvm/arm/vgic/vgic-its.c +++ b/virt/kvm/arm/vgic/vgic-its.c @@ -421,6 +421,7 @@ static int its_sync_lpi_pending_table(struct kvm_vcpu *vcpu) u32 *intids; int nr_irqs, i; unsigned long flags; + u8 pendmask; nr_irqs = vgic_copy_lpi_list(vcpu, &intids); if (nr_irqs < 0) @@ -428,7 +429,6 @@ static int its_sync_lpi_pending_table(struct kvm_vcpu *vcpu) for (i = 0; i < nr_irqs; i++) { int byte_offset, bit_nr; - u8 pendmask; byte_offset = intids[i] / BITS_PER_BYTE; bit_nr = intids[i] % BITS_PER_BYTE; From patchwork Mon Dec 4 14:03:35 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoffer Dall X-Patchwork-Id: 120542 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp4473644qgn; Mon, 4 Dec 2017 06:04:47 -0800 (PST) X-Google-Smtp-Source: AGs4zMZaZCgxRAO1+wK8jS+cHuHYky8WFuTi1Y4Tp9WftmXx2lyguv1KMt+nZLDPwm1KC1X+bEBo X-Received: by 10.99.56.26 with SMTP id f26mr14065031pga.328.1512396287624; Mon, 04 Dec 2017 06:04:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1512396287; cv=none; d=google.com; s=arc-20160816; b=G/F4aXAJfCwr93N+GaY2pHpqojV/3aSlVogmaj4CEGH2nLQbjYMFkZfM8i+ePfmsMU qDuv/6kxXsVoxqmWP0rJRgJJiGvOO+LU7fUbS804A4U8Sq3EyWJQyW3IFSwuhSKj6Fr8 3fRv8wrM7BQgGexz+9UN6EdzM4yBX3pm21GbeieES4mETpDvtW4x3tHy1KpUJMv0MAAz zBRA0OHXY6Jol1WUAvkqvTKSqXHSxpPJm2jkHK/hldrmUxKLGe6YhRRFvNguOlixA2Wx hknM9r+dKUaddwh1ASBIe3zVTUj2UZTCgwSf+y5zVWcSE+nBU2LPDh4WL5qxzGe4b79X 4VVQ== 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=Ra6rBB7vxGZBSnUQmdGR9FHiTTk16dI2fMJB2o8axq0=; b=HQ+QiI6fdHNfa/gAK95fXdUSe252AM/XSq1Kc8ge7ItTWP+gGZIH1HeTQ2t/BivxT8 MvgqFIoSLtpjh9VwhhsZotfW5mi+BCwCaNO+TzqIeeEADHePFyAGVfxdX2xQbmnifDPs B4nNXPCEgFV4hUZXwY2X+d0mgsmKY8M4xlgvd2XRrX3P3+ILwO24DvDDr5xrd5p33Ej7 B1DISxIArXrr1NoeXamEo7F30PtYLMDufvCSjDOoPD/xLSOyu5n5L+9zp2kGkxQde+s9 GKC8b07yfexfn6s8u8t2kxDpFDIozGGR/mrjIfQRgbLGJNVYqIFpaN/FPblH/oRDhLJ5 oFZA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@christofferdall-dk.20150623.gappssmtp.com header.s=20150623 header.b=VWUudRDw; 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 bc11si9621880plb.422.2017.12.04.06.04.47; Mon, 04 Dec 2017 06:04:47 -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=VWUudRDw; 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 S1754482AbdLDOEK (ORCPT + 9 others); Mon, 4 Dec 2017 09:04:10 -0500 Received: from mail-wr0-f195.google.com ([209.85.128.195]:39864 "EHLO mail-wr0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754288AbdLDOD5 (ORCPT ); Mon, 4 Dec 2017 09:03:57 -0500 Received: by mail-wr0-f195.google.com with SMTP id a41so15543388wra.6 for ; Mon, 04 Dec 2017 06:03:56 -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=Ra6rBB7vxGZBSnUQmdGR9FHiTTk16dI2fMJB2o8axq0=; b=VWUudRDwAYOSHR2E5Q5pWP6oMNhZxjvahu1XUFmnOVlMx9jqxwU35cF9sZUFy4fO3k uXMfLaNmaUElvJf5CvON5dh4lYpUDL9h2zF8ugiTyuWagpVd3XJCafJhTnPOipdIkWpE JiE0afOsCb7HXC4ErjQQfUsVU9d3Zh2Sp0n6NqDTqL5DSEQHSICF4dvZEApgB5uSmO4X 82lTTVb4/Hb0DBL6oAtuuC49DD6Q534AJHpryRViWj3r2ZUbjk8qXn3szF1Y+pEebpET 1gAtgpjRIZ/uFfubVqeSOczRORL1IGUB5V5FtSmDNezpK5KXkdyrsJgg5Jdw8Tyhz7PE Xxng== 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=Ra6rBB7vxGZBSnUQmdGR9FHiTTk16dI2fMJB2o8axq0=; b=S4Eh6bPTnotOO/0b4NKFs3Wy/BgRaHo0QuV17wCjVf/VE8f+peh1BcTDRdQzTXBCdu a0m5pAf/HNt8vCB5tLXEtE7e5Ovw3dbJ/wtKvjNOQbMEpTmRSC6iscdQ8NbdwZiC61Ul Fh96QFD5v2ANtQ2B7mnoszXtgWYF0QSrNWHEmrVbQ5tQV11Y1tkNVliLflAuOzQl2l/W UWjuXuewoU2mIlgOKrA63mfN6PiR2VjVKcYP18g5gNmPCv9SBBCIK2Gzf8EPXryFQ3A9 oiQhyrbUEeZlG5Q26JdCPNKSy7IRp6jcUvIL/qOn0A4SP8AOJruNdK6F1WQucDzTrzKh d9Jw== X-Gm-Message-State: AJaThX6TxT+J/sliMGXO8TuIGA1NS2Bd8pbh6LKqaGizoWxMBdRzBzGl 42+Mshh7muWU2ZMYIoYbCQnaHQ== X-Received: by 10.223.170.150 with SMTP id h22mr13010188wrc.26.1512396235635; Mon, 04 Dec 2017 06:03:55 -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.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 04 Dec 2017 06:03:54 -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 06/19] KVM: arm/arm64: vgic-its: Check result of allocation before use Date: Mon, 4 Dec 2017 15:03:35 +0100 Message-Id: <20171204140348.21965-4-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 We miss a test against NULL after allocation. Fixes: 6d03a68f8054 ("KVM: arm64: vgic-its: Turn device_id validation into generic ID validation") Cc: # 4.8 Reported-by: AKASHI Takahiro Acked-by: Christoffer Dall Signed-off-by: Marc Zyngier Signed-off-by: Christoffer Dall --- virt/kvm/arm/vgic/vgic-its.c | 2 ++ 1 file changed, 2 insertions(+) -- 2.14.2 diff --git a/virt/kvm/arm/vgic/vgic-its.c b/virt/kvm/arm/vgic/vgic-its.c index cb2d0a2dbe5a..8e633bd9cc1e 100644 --- a/virt/kvm/arm/vgic/vgic-its.c +++ b/virt/kvm/arm/vgic/vgic-its.c @@ -821,6 +821,8 @@ static int vgic_its_alloc_collection(struct vgic_its *its, return E_ITS_MAPC_COLLECTION_OOR; collection = kzalloc(sizeof(*collection), GFP_KERNEL); + if (!collection) + return -ENOMEM; collection->collection_id = coll_id; collection->target_addr = COLLECTION_NOT_MAPPED; From patchwork Mon Dec 4 14:03:37 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoffer Dall X-Patchwork-Id: 120541 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp4472758qgn; Mon, 4 Dec 2017 06:04:11 -0800 (PST) X-Google-Smtp-Source: AGs4zMYz+hiTdIB2QIfsF4Wc5D7Tc3eeauYohmmLC5U+ADlSF2x6YR27nGyd34Wsmjz4zwUU+AgN X-Received: by 10.84.175.67 with SMTP id s61mr8910938plb.72.1512396251498; Mon, 04 Dec 2017 06:04:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1512396251; cv=none; d=google.com; s=arc-20160816; b=ZShm0qsuwuzs2b8j3tScKy6CO+7ayxIHSWgG0VL/gTz+LBHjhm/hLbFll+LAzMbR2u 4Z3GRtfXk+HLyWtIvmoHhwAxHPV6WRQQzuapjwFiQipqQdSHDvO+AoNNWTe4oaunsDIy j+0BmI9oU0J4Brf2vBz6Jx9gvN0E7jAc5MXIcUBSia+MHyGbEYDDWRFb6xl+Ri/F/hHa pMFrxnfxx37q/S7b2tJ3rbomV6FZt6Jic7NW/rlJfcHT7gsFizvgvqeQhg8pbJO3q/tw ROojBmqwOAYCsfYhWXRpdTgQZ4ScS71B9P3lkNxuOaq5wx2uFc9Fb2PyxLk/VTtTGgI+ rwLQ== 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=+CusPMXYVrjOVmHAylBHwzDxwi7kqn3PcS/X5orpTAs=; b=WJ2s5ypy05s7Iq2N453z/a7QKxrmuwf1jhKlg2/3J6ugeIYQUBCi62yIzP7Q44YCIu VTdUiGD/l0gNZPxPpcORJLbwrDG6qXISnFc4lbIVQua1nuHHDH2b0DO6BJ2NiymZXcW0 JtsY4UoVJEXURm0jk/TqTyZ6ZnuW6FDKAfKYpFGY8Ge/FYtwujg49xMs5AV9xdbW7+Gv x4uJwMTZ/b3m+0cjyEmvZ6/RpWT8MW/FXQ/WAvMPKa6SxrdGjAvg4ySvG43hV5g3PM5w qLEcS9ghnBX+ioPgspk1e5O+4uwa4q2KE6FmBV2WbfZzkGKXEnb2aVe6ZyJ76A2ZqG0A lZKg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@christofferdall-dk.20150623.gappssmtp.com header.s=20150623 header.b=Dsjk1uz/; 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.11; Mon, 04 Dec 2017 06:04:11 -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=Dsjk1uz/; 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 S1754464AbdLDOEI (ORCPT + 9 others); Mon, 4 Dec 2017 09:04:08 -0500 Received: from mail-wr0-f194.google.com ([209.85.128.194]:38627 "EHLO mail-wr0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754380AbdLDOD7 (ORCPT ); Mon, 4 Dec 2017 09:03:59 -0500 Received: by mail-wr0-f194.google.com with SMTP id o2so17413034wro.5 for ; Mon, 04 Dec 2017 06:03:59 -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=+CusPMXYVrjOVmHAylBHwzDxwi7kqn3PcS/X5orpTAs=; b=Dsjk1uz/W2mdSpCVwtyW/UJhod70IDC63LoU+ksX2Ex1GIT9OXsWepLkG5wRBXNWXG R+nMYmRFJRosM0oj2KDLM8ZRzqCuwHkOxrKOtczxAj8+I1XuMO0BYbbiBAxM7lu6DQHF bzOqLfxm8szjcGW8WJSbIj/zA6i/BVx55CFCEl3qJJWOOSg/sOyGpYXQvZP+BcKSOxlk uAivV7a44BoyVOW8SZw3fRho1mMGR1jxvW/k4Av+G0KYGKKTNjRbm3CvzOhn5+PlVc3l SlFohQNIhXuRqU1PyA+kW9dPcgCyELJd3a6s/mk1nhcBHTMiL4FcZtPH6uFBWQMohq1I mSsQ== 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=+CusPMXYVrjOVmHAylBHwzDxwi7kqn3PcS/X5orpTAs=; b=PYYTLd4xDGiUTxHvizIkrm3iFsdAWNiYCZ48EI3BA0EF6I6/IRbU6Uu0aHCXjanUoN KlYbN1mqwju0EpGkVm0z3hvPsnbw+IsJySoEPTA8AxXZsHo3OmUruRJufVS2H9wAgZlv Xlf2k5uLVUql7gZ0kZ0aIponX8OJ2aUSmKn4WCAC0nRQpiP6MIxhxYkfoHl/7bEKc5x9 chjqzPXGxeMNQ5J6ytblmZ05KYP7Q9UFkFof/fZPm4ObIABAC8z5tBlQx7II56L0WwP+ skMigWEFET5UcAy8IQv21A9EvrgdBQHQ1MX1yj3+T5wd6skvSCDP6zMLAx72nedXhd8v 2qUA== X-Gm-Message-State: AJaThX6z/+XWKyPu32ndcbQtPBUTGg+RNhO/FGBhVgalqyvb71jHsDQP 0y270z1PeQv/Lyd8otYZC93bGw== X-Received: by 10.223.174.147 with SMTP id y19mr12538334wrc.97.1512396238361; Mon, 04 Dec 2017 06:03:58 -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.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 04 Dec 2017 06:03:57 -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 , Kristina Martsenko , stable@vger.kernel.org, Christoffer Dall Subject: [PULL 08/19] arm64: KVM: fix VTTBR_BADDR_MASK BUG_ON off-by-one Date: Mon, 4 Dec 2017 15:03:37 +0100 Message-Id: <20171204140348.21965-6-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: Kristina Martsenko 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 47-bit addresses (instead of 48-bit) and also insufficiently checking the alignment. This patch fixes it. As an example, with 4k pages, before this patch we have: PHYS_MASK_SHIFT = 48 VTTBR_X = 37 - 24 = 13 VTTBR_BADDR_SHIFT = 13 - 1 = 12 VTTBR_BADDR_MASK = ((1 << 35) - 1) << 12 = 0x00007ffffffff000 Which is wrong, because the mask doesn't allow bit 47 of the VTTBR address to be set, and only requires the address to be 12-bit (4k) aligned, while it actually needs to be 13-bit (8k) aligned because we concatenate two 4k tables. With this patch, the mask becomes 0x0000ffffffffe000, which is what we want. Fixes: 0369f6a34b9f ("arm64: KVM: EL2 register definitions") Cc: # 3.11.x Reviewed-by: Suzuki K Poulose Reviewed-by: Christoffer Dall Signed-off-by: Kristina Martsenko Signed-off-by: Marc Zyngier Signed-off-by: Christoffer Dall --- arch/arm64/include/asm/kvm_arm.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) -- 2.14.2 diff --git a/arch/arm64/include/asm/kvm_arm.h b/arch/arm64/include/asm/kvm_arm.h index 7f069ff37f06..715d395ef45b 100644 --- a/arch/arm64/include/asm/kvm_arm.h +++ b/arch/arm64/include/asm/kvm_arm.h @@ -170,8 +170,7 @@ #define VTCR_EL2_FLAGS (VTCR_EL2_COMMON_BITS | VTCR_EL2_TGRAN_FLAGS) #define VTTBR_X (VTTBR_X_TGRAN_MAGIC - VTCR_EL2_T0SZ_IPA) -#define VTTBR_BADDR_SHIFT (VTTBR_X - 1) -#define VTTBR_BADDR_MASK (((UL(1) << (PHYS_MASK_SHIFT - VTTBR_X)) - 1) << VTTBR_BADDR_SHIFT) +#define VTTBR_BADDR_MASK (((UL(1) << (PHYS_MASK_SHIFT - VTTBR_X)) - 1) << VTTBR_X) #define VTTBR_VMID_SHIFT (UL(48)) #define VTTBR_VMID_MASK(size) (_AT(u64, (1 << size) - 1) << VTTBR_VMID_SHIFT) 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) From patchwork Mon Dec 4 14:03:48 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoffer Dall X-Patchwork-Id: 120543 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp4473674qgn; Mon, 4 Dec 2017 06:04:48 -0800 (PST) X-Google-Smtp-Source: AGs4zMZVnsfrRuvp13iZX5aPXzrYMuKaZUJmu0dacQxl/bx+B2aLKSAX1x0Qt/V8yjOt072+t1sa X-Received: by 10.101.81.72 with SMTP id g8mr14104538pgq.135.1512396288602; Mon, 04 Dec 2017 06:04:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1512396288; cv=none; d=google.com; s=arc-20160816; b=HEe6DB4XVK6zPHWBUWY1W/KW/yBzOfpM3t2JA8kfb9kEaxr0FrRFH+DnjT/I6mITL/ 74z7WPVr8eujqpR4LZnAydx0TszmXzu6lj4hbH5ZSeBtKbIHDPegIRMkErxA5y2f0lyL M4+Vbep1yLuNrbBYE/2F0WqaJcWOTrTUhtwlkkR2Ir3LNG6FTCr/YYSdXMQ5IOcZ6++o laifCGJ6HGffvi85QqaHmTEOslrevYI61oMjm6V9U3caAr9NzjDAjf3MF7zmgOEFUP6f CGUNr3r8uENXc6rUzOe5VvophhMYssyh0Ohuasf8/njOG+2Ag3liOIANs4wZWX52sSCx jClg== 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=VYxmL+PZNurnmoYpZ7X7QGf0B46epS0TWuDGYyV98VI=; b=BwVxpV94oyKxtuC7IA6OQx1kABeZ7xstUACOUL8Y/tmku9QBAR4NXFarJDLREBcZhE H6us03ayqI0eeSivgXmFZZE3g5rl6XR8Ve6T2O8cdJ26t4lhFHzAubxZzEcQClrhL+70 rqlvs8nq66S6q0SZQMgMmGNNMXqK2OXz5sxmFz050XfPgDJOMoSKQ6MxAjijW4eMShKI 6MoOG8BQwp/0KLm6cp5+fd0q9Ob7v5J7DawKJBB8AKfSx5s0BRcTbsgvWEtaJn1WuDp3 JLa538dYqqMe0MVDpHcyLm4Bd8bgUlH1ikBN2OSFvFQJ+b0WKIudgI2T8ra/l1794aSr tHUw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@christofferdall-dk.20150623.gappssmtp.com header.s=20150623 header.b=EhnGxpRq; 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 bc11si9621880plb.422.2017.12.04.06.04.48; Mon, 04 Dec 2017 06:04:48 -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=EhnGxpRq; 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 S1754246AbdLDOE0 (ORCPT + 9 others); Mon, 4 Dec 2017 09:04:26 -0500 Received: from mail-wm0-f66.google.com ([74.125.82.66]:42677 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754487AbdLDOEO (ORCPT ); Mon, 4 Dec 2017 09:04:14 -0500 Received: by mail-wm0-f66.google.com with SMTP id l141so6007979wmg.1 for ; Mon, 04 Dec 2017 06:04:14 -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=VYxmL+PZNurnmoYpZ7X7QGf0B46epS0TWuDGYyV98VI=; b=EhnGxpRq4srcQQwPlbKAYJzdpW53Agv3lZjtjkdhIj7WWqBgPuyCzQD+ui7A7xrQwb ec78BydyisNjd0XchFM+A8IkOOCnmL+bG2s6cS1pbyyB+cVXwqo2XLhMIhcQNQtZNLrE ECxLeydHHOXg6a3KegujrpNOutZMDKGZKDs7kA5O/ggjJIoKceFw5bqS8T12zXqhD+9y chOY+USFn9+N3hJ3WfODv/8rVjG+NWCZ06Ximcc5WiTMDiEaY+sHBBssP41ugR0qX+Vv mlHjfUuvrcuiQ+g5fPYTVNpXJI3na/1RRj1F/20Ny01DolSGXE1MRrV/FtAYuzH3o0Rd jhmA== 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=VYxmL+PZNurnmoYpZ7X7QGf0B46epS0TWuDGYyV98VI=; b=J7tHzXNSwHkriw+jlOs29LhT8Uto6rDJ3tEfzfRTDlJZn1Wz41YoQOZpqby2FYGIei YDAPE702e6VqpiglrZaAx2uSr+7CDGrl8g6JCz4YjqQAYzhW/XYsgFpERRt504C99fRh 19Z/FDK1VEBgeQOOHhNfzBheF7WwQZTtSjzvirgik1yB89n3BAwMPXy2EaV40DKEuh0L fDpzPFv7HTgA+xeK2eLv67iIZKMISxQkq7tfeBO3XCdoMHKu4hBa/UD0P6prQK8gUwDK fSbI3Z2sTi0vpp+F6K4jou/34Vfjk9dzUR9fHHniS8iRqTPzUruWYyIuQE6g9ecNlNHl rPKA== X-Gm-Message-State: AJaThX712C7UPOzkpBgLDE1K0EX2gnj4cXHIYlWbaE9a3LMrAL8ufdv0 qLvyZ8wln8Ta5my34AGgX/Ubjg== X-Received: by 10.28.28.5 with SMTP id c5mr7459230wmc.115.1512396253343; Mon, 04 Dec 2017 06:04:13 -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.04.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 04 Dec 2017 06:04:12 -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 , Christoffer Dall , stable@vger.kernel.org Subject: [PULL 19/19] KVM: arm/arm64: Fix broken GICH_ELRSR big endian conversion Date: Mon, 4 Dec 2017 15:03:48 +0100 Message-Id: <20171204140348.21965-17-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: Christoffer Dall We are incorrectly rearranging 32-bit words inside a 64-bit typed value for big endian systems, which would result in never marking a virtual interrupt as inactive on big endian systems (assuming 32 or fewer LRs on the hardware). Fix this by not doing any word order manipulation for the typed values. Cc: Acked-by: Christoffer Dall Signed-off-by: Christoffer Dall --- virt/kvm/arm/hyp/vgic-v2-sr.c | 4 ---- 1 file changed, 4 deletions(-) -- 2.14.2 diff --git a/virt/kvm/arm/hyp/vgic-v2-sr.c b/virt/kvm/arm/hyp/vgic-v2-sr.c index a3f18d362366..d7fd46fe9efb 100644 --- a/virt/kvm/arm/hyp/vgic-v2-sr.c +++ b/virt/kvm/arm/hyp/vgic-v2-sr.c @@ -34,11 +34,7 @@ static void __hyp_text save_elrsr(struct kvm_vcpu *vcpu, void __iomem *base) else elrsr1 = 0; -#ifdef CONFIG_CPU_BIG_ENDIAN - cpu_if->vgic_elrsr = ((u64)elrsr0 << 32) | elrsr1; -#else cpu_if->vgic_elrsr = ((u64)elrsr1 << 32) | elrsr0; -#endif } static void __hyp_text save_lrs(struct kvm_vcpu *vcpu, void __iomem *base)