From patchwork Tue Jan 16 17:02:31 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoffer Dall X-Patchwork-Id: 124751 Delivered-To: patch@linaro.org Received: by 10.46.64.148 with SMTP id r20csp1080511lje; Tue, 16 Jan 2018 09:02:54 -0800 (PST) X-Google-Smtp-Source: ACJfBotj6hCJ3r4vJwHndn+kMGu3FtlDTyuupwE+1U4IUyViozCFlYekjGih1yUL9kS3ENjmuNdN X-Received: by 10.84.253.148 with SMTP id a20mr38540444plm.216.1516122174691; Tue, 16 Jan 2018 09:02:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516122174; cv=none; d=google.com; s=arc-20160816; b=r5MrNRZ289fFoGrAtxcBHgt6Vnx9EXRWjf1oHoIOz/crObp7rzChJt4II5E49YB5hy SmlmiTTem/O4s6UjDHprRT0gtl1iPOhgA33qnk5VE9bby3Z28j+Af8nAXpB1TOd2Slxz yE+FDFJt6llBgHMxI1UZlhnM2Giwj3efXF16nF8KXE3wBGzWdb8vgQ1xsZYg705EUWWC kang0TjOOb2zGrgXWz45F0JmxoQ2V8boAS5o+zvx1eFf/oqsNRJKVZCGqwJKeX+fuTLj nrKjhFS3fnF+gZzKKSalUi87BRSLuml3tU1yiuR6TSrSHXz1TfgqrEG+h1xH+hUfLirU EjxQ== 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=N/5CM2WExP+3Sg/y66D4RldSXLI/4HOx6RZ1zsknEA8=; b=urNFgUqLXyjjbRV+VDh4zy6MYlr9+BflFC5Q+EowIumB602ainxbLOeIIIcLOO5T1M XcdkpSHAv7x5xe67GxgjImWpoKk6S4V+hnXoCVr2cVEAwKjG54SOMOvLu3+pyqnJMPNB FCrekdCPSXfekg41sQji7x8Hm9WqceEnu0DY+f4C5bUtx1y4JPzj7uIyKGt3FbFJv3fF SWMADSV5d/ePBXCnVMfcZWC2CG4GCJHNVQ64RvqOc71VHNw8LbEJloWnntL9mzQf2Yqr WZHe8rOWvJAUXzRxByRaLjQudsM2G1fcRhdbZWx8npxsloyxMQHats86A1SbUJ+62oJw TKlw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=FkOXRyXy; 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 u196si1956542pgc.116.2018.01.16.09.02.54; Tue, 16 Jan 2018 09:02:54 -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=FkOXRyXy; 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 S1751375AbeAPRCn (ORCPT + 10 others); Tue, 16 Jan 2018 12:02:43 -0500 Received: from mail-wm0-f67.google.com ([74.125.82.67]:37159 "EHLO mail-wm0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751070AbeAPRCk (ORCPT ); Tue, 16 Jan 2018 12:02:40 -0500 Received: by mail-wm0-f67.google.com with SMTP id v71so10106470wmv.2 for ; Tue, 16 Jan 2018 09:02:39 -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:in-reply-to:references; bh=N/5CM2WExP+3Sg/y66D4RldSXLI/4HOx6RZ1zsknEA8=; b=FkOXRyXyNJZp2QA2jY6HWoa9JGlO+WKmk2CgcyIFwJhUbdSgs9+SGrMyvcGIlGmvBJ IpDzsmqhCKCCqpEFdx75+8wIJq7iW/4Q1V55M/OSQFBFYhBWgi7joPNwabF4jNdki3q7 to760LZ2DVoxlkuNb6GVG5HP2SneWw8F4MN9Y= 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:in-reply-to :references; bh=N/5CM2WExP+3Sg/y66D4RldSXLI/4HOx6RZ1zsknEA8=; b=gEF/BruGlBGL7ZLptfv3amTcvGUTJQWW7dkkoLvj/tsVpJyxowDUZJ07PrIo0iT2EY ksyqhHMVTFDIB3EkTfJKw1Jg8Jg7GKZkfMDQfbVtH5umLBsbkbeZgiZStM/DniYHQHaN aGogE3OnbTsqUu2aaDo2yM6D0uyhjQ/D70IaxkXMDeohtyRSDLSLHoHurfBIRgjHsF5b 2eFsqkDJPZqf+VpYnmDaVtoSUZ0SEasqGuCsY4d7IHwNx8bz8wux1S7yQGAK75/sVRel IaJtfHoKNkRsBCMZfiePhNRnUuXT5EcG5B0kO2SxkHx2eqPl5f5mTc+y0XK1a9eZaQXy Oeaw== X-Gm-Message-State: AKGB3mKYcN7wRGrPRr3o9qC/BVhL9ltZNANBHMPtOVF4x34XPKXw+BVd jh6RxTKVUwGsOnq9VAbGXJ4Z6A== X-Received: by 10.80.202.7 with SMTP id d7mr54755679edi.32.1516122158908; Tue, 16 Jan 2018 09:02:38 -0800 (PST) Received: from localhost.localdomain (x50d2404e.cust.hiper.dk. [80.210.64.78]) by smtp.gmail.com with ESMTPSA id r29sm2107162edl.82.2018.01.16.09.02.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 16 Jan 2018 09:02:38 -0800 (PST) From: Christoffer Dall To: Paolo Bonzini , =?utf-8?b?UmFkaW0gS3LEjW3DocWZ?= Cc: Marc Zyngier , linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, Punit Agrawal , stable@vger.kernel.org, Christoffer Dall Subject: [PULL v2 1/3] KVM: arm/arm64: Check pagesize when allocating a hugepage at Stage 2 Date: Tue, 16 Jan 2018 18:02:31 +0100 Message-Id: <20180116170233.7085-2-christoffer.dall@linaro.org> X-Mailer: git-send-email 2.14.2 In-Reply-To: <20180116170233.7085-1-christoffer.dall@linaro.org> References: <20180116170233.7085-1-christoffer.dall@linaro.org> Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Punit Agrawal KVM only supports PMD hugepages at stage 2 but doesn't actually check that the provided hugepage memory pagesize is PMD_SIZE before populating stage 2 entries. In cases where the backing hugepage size is smaller than PMD_SIZE (such as when using contiguous hugepages), KVM can end up creating stage 2 mappings that extend beyond the supplied memory. Fix this by checking for the pagesize of userspace vma before creating PMD hugepage at stage 2. Fixes: 66b3923a1a0f77a ("arm64: hugetlb: add support for PTE contiguous bit") Signed-off-by: Punit Agrawal Cc: Marc Zyngier Cc: # v4.5+ Reviewed-by: Christoffer Dall Signed-off-by: Christoffer Dall --- virt/kvm/arm/mmu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.14.2 diff --git a/virt/kvm/arm/mmu.c b/virt/kvm/arm/mmu.c index b4b69c2d1012..9dea96380339 100644 --- a/virt/kvm/arm/mmu.c +++ b/virt/kvm/arm/mmu.c @@ -1310,7 +1310,7 @@ static int user_mem_abort(struct kvm_vcpu *vcpu, phys_addr_t fault_ipa, return -EFAULT; } - if (is_vm_hugetlb_page(vma) && !logging_active) { + if (vma_kernel_pagesize(vma) == PMD_SIZE && !logging_active) { hugetlb = true; gfn = (fault_ipa & PMD_MASK) >> PAGE_SHIFT; } else { From patchwork Tue Jan 16 17:02:33 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoffer Dall X-Patchwork-Id: 124750 Delivered-To: patch@linaro.org Received: by 10.46.64.148 with SMTP id r20csp1080483lje; Tue, 16 Jan 2018 09:02:50 -0800 (PST) X-Google-Smtp-Source: ACJfBotS/4zo3LnU6KO7TvpCm+L1RwxmfqTJ0tXqoYTLIDX77p6ut34gbkabPK4riJtjYuUK8aZA X-Received: by 10.84.235.196 with SMTP id m4mr40197269plt.118.1516122170746; Tue, 16 Jan 2018 09:02:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516122170; cv=none; d=google.com; s=arc-20160816; b=VhBJLTSK3f7qTYAOdiM8tbL7t3DHnuxEp1TaDn1nOangELCuJwKXXCCHOHlcFOoUXW KGz3Z8rxnZo8lvJEhlfZO+t9kvrszLKOr3Tt0q1Qm+0y3Gg3hJ7na/jq6F65iRTKuKSQ bFI5v/DIJ3P6N/tT/r8YUzvCYBoVsdbk6HBXeUgZiFmwHlu8x+tfslUb1SU/vCZC5buE OqnRJO4W94pxPJ9TqEZVwPCGsGQJ4+CVAQDAsipaXg4hes7pYa/7HlGTyik3T+nKlM5d eg8Oikrd5v9bwgNS1leQKOtfL6v809K0Fyku06yTHuoLs9ANYkDuW7xfQR1Sb4P5f2pu H4Bw== 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=dIgbhP3BAG5JtdprNvNXJy0jvAfw6BWSiFZ2vKILMAQ=; b=0oelV2jak7VO4MRD2rt5VhRLuIunnP4iLNzELQQkHX/0NvN65+MDdGSqhGnGr9xl7g E6+JU82D1WtLtZrGp/Oy86RXsKR8veSG18ob+UU8mMufUARe2AzRhork4+ffhfjuZygD gZWi2wkL/Vk00f3bz+1b/yNdy7eA+27xvCYHsmYPDg01f5UsfyGTlJktOFOEHsGKZHuE QjAFTOlRFR6xTiGSyQN8aXmgTeFw8mAe5vP2vKr5uixUo714gaQxqKPrXVqf1lBlIIWK prAt+u8G/Zzo0eJZ1b87ONvoId0y6R0nZ3mDk6pY1aXHEmWdlDb26NUqbuN/HNtCvS9b erzg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=K4KRlCZR; 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 u196si1956542pgc.116.2018.01.16.09.02.50; Tue, 16 Jan 2018 09:02:50 -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=K4KRlCZR; 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 S1751296AbeAPRCq (ORCPT + 10 others); Tue, 16 Jan 2018 12:02:46 -0500 Received: from mail-wm0-f67.google.com ([74.125.82.67]:45093 "EHLO mail-wm0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751365AbeAPRCn (ORCPT ); Tue, 16 Jan 2018 12:02:43 -0500 Received: by mail-wm0-f67.google.com with SMTP id i186so9740135wmi.4 for ; Tue, 16 Jan 2018 09:02:42 -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:in-reply-to:references; bh=dIgbhP3BAG5JtdprNvNXJy0jvAfw6BWSiFZ2vKILMAQ=; b=K4KRlCZRZn7PSkRdxiGM0VSvfva+9g2MadQedMVnVhgiEQ6hz9TJt5716dM+VELqAA bwiseM8JZxG7+MeByDvxgmj6GE/LQ7MH7FupLc4GUx1t1cGmGBUBoFCVSIhS0q1w+uk4 teDbnrlzvGsmoiTHUf4tzsvD/0n4XFlUGM0Qs= 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:in-reply-to :references; bh=dIgbhP3BAG5JtdprNvNXJy0jvAfw6BWSiFZ2vKILMAQ=; b=Z1g4LIZFOjmox/OEf4IGZQpA6WA5TtG+56fnFOZWNBRQjbUTRB2lH5NfX8PshhtUZ6 nlXyEFzMFDYezHXy8IAefQOoPynhUHRt+7MdMczj5Te6qfaD7FFDOMdwr04hxvM51Fn6 z/ILdzROv78n6n4nuzN4lJQWMHx5tTzTnStOr0+OjGEaFIaq9nKsIWylpzDjAqdaGurM HwivxgRJUdCVJXqw2ApU6QNEEzgiq2iSs/krrOnfgoPVzkU+EXoRtKRpq0qs10R//cDu KCiUdxtmy6UgJm5gBRJt5dG4gOe6N+ziP4fU9izGO0heEMWjXlnZnHQ1/3/ppOr6lXA1 NzBw== X-Gm-Message-State: AKwxyte83P+6hfUB1TWrNlVEJ01KkzixpfIp07Vk1ZnU2woGSOpLAFI2 c2eALqZQsdqFAEiCmHe0VC88cw== X-Received: by 10.80.242.144 with SMTP id f16mr14537485edm.52.1516122162044; Tue, 16 Jan 2018 09:02:42 -0800 (PST) Received: from localhost.localdomain (x50d2404e.cust.hiper.dk. [80.210.64.78]) by smtp.gmail.com with ESMTPSA id r29sm2107162edl.82.2018.01.16.09.02.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 16 Jan 2018 09:02:41 -0800 (PST) From: Christoffer Dall To: Paolo Bonzini , =?utf-8?b?UmFkaW0gS3LEjW3DocWZ?= Cc: Marc Zyngier , linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, stable@vger.kernel.org, Christoffer Dall Subject: [PULL v2 3/3] arm64: KVM: Fix SMCCC handling of unimplemented SMC/HVC calls Date: Tue, 16 Jan 2018 18:02:33 +0100 Message-Id: <20180116170233.7085-4-christoffer.dall@linaro.org> X-Mailer: git-send-email 2.14.2 In-Reply-To: <20180116170233.7085-1-christoffer.dall@linaro.org> References: <20180116170233.7085-1-christoffer.dall@linaro.org> Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Marc Zyngier KVM doesn't follow the SMCCC when it comes to unimplemented calls, and inject an UNDEF instead of returning an error. Since firmware calls are now used for security mitigation, they are becoming more common, and the undef is counter productive. Instead, let's follow the SMCCC which states that -1 must be returned to the caller when getting an unknown function number. Cc: Signed-off-by: Marc Zyngier Signed-off-by: Christoffer Dall --- arch/arm64/kvm/handle_exit.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) -- 2.14.2 diff --git a/arch/arm64/kvm/handle_exit.c b/arch/arm64/kvm/handle_exit.c index 304203fa9e33..e60494f1eef9 100644 --- a/arch/arm64/kvm/handle_exit.c +++ b/arch/arm64/kvm/handle_exit.c @@ -45,7 +45,7 @@ static int handle_hvc(struct kvm_vcpu *vcpu, struct kvm_run *run) ret = kvm_psci_call(vcpu); if (ret < 0) { - kvm_inject_undefined(vcpu); + vcpu_set_reg(vcpu, 0, ~0UL); return 1; } @@ -54,7 +54,7 @@ static int handle_hvc(struct kvm_vcpu *vcpu, struct kvm_run *run) static int handle_smc(struct kvm_vcpu *vcpu, struct kvm_run *run) { - kvm_inject_undefined(vcpu); + vcpu_set_reg(vcpu, 0, ~0UL); return 1; }