From patchwork Thu Dec 3 08:25:22 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 57624 Delivered-To: patch@linaro.org Received: by 10.112.155.196 with SMTP id vy4csp3360663lbb; Thu, 3 Dec 2015 00:27:23 -0800 (PST) X-Received: by 10.98.75.83 with SMTP id y80mr11092634pfa.77.1449131243222; Thu, 03 Dec 2015 00:27:23 -0800 (PST) Return-Path: Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id xi10si10595597pab.18.2015.12.03.00.27.22 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 03 Dec 2015 00:27:23 -0800 (PST) Received-SPF: pass (google.com: domain of linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org designates 2001:1868:205::9 as permitted sender) client-ip=2001:1868:205::9; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org designates 2001:1868:205::9 as permitted sender) smtp.mailfrom=linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org; dkim=neutral (body hash did not verify) header.i=@linaro-org.20150623.gappssmtp.com Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1a4PDB-0008Uo-18; Thu, 03 Dec 2015 08:25:57 +0000 Received: from mail-wm0-x235.google.com ([2a00:1450:400c:c09::235]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1a4PD7-0008AN-FT for linux-arm-kernel@lists.infradead.org; Thu, 03 Dec 2015 08:25:54 +0000 Received: by wmec201 with SMTP id c201so11491796wme.1 for ; Thu, 03 Dec 2015 00:25:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id; bh=QG6Gf47I2qNWT76FPIid6m3rNUYUfxiWnEsBvlpNQUQ=; b=TUj36MMP35XEm18mzW1xez70GG4bUdnh7Ym3kEaROmKO5xFWIjb+eoBqDxIfe1VG2R flYgBKhH3/OAFbM6WxoXb95BoIm2gAT1vB3M/SnMq+B/+s+G24imEHI2GRLElyMY4KAN 3i7W4eDez7Z6qqxBb5cAUE46UyDen4e6hFCeBqEyXSGQRPoWrbgKIyEG1rvKFM83QB6I kbfs9orP2oQAgO0ND7oP9JMfqBWUKKEl6UT/+HMWuR0dhiwk4DTMqrPTonFP5ywp6AcU kTysrS3N7u+DeI0OwTpjVdAGOuo1PiyMtxtAanFp0wxhzTmeUrAlf9zmi5fCLJeXKw9I C8hA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=QG6Gf47I2qNWT76FPIid6m3rNUYUfxiWnEsBvlpNQUQ=; b=I6/iwfmrYFz+VYBBGm7E4AJJGBB8vu2S+QiWq52qmgNpeATgOs167UxqTzSwwfM22J 50AjPTma4WrOi6OvtZS4DwRyoMpo4PJR0HM5WpuIrcj7mF7zBAvGO51Ga2yDpwvvV4cQ 1jZdeGpGDRHbSPRfBffpOh+c9rX6As5Rn4Pjo5e7+RVG7AIQcp21m8lti19e3WSZ8Cmv pNZKP5y48YC2kKsoGF+M7gpSn7h0leWz9EArQTcFssusZVxD4a3Z8Xgy/EACAxyNp7i5 c6XKf9l7Z61QOswwWqXXxVTavhX+Anv16MHwP+Nt5UAeU9H/8NaBN6waXkfyKo447O+d UPug== X-Gm-Message-State: ALoCoQlglgViE+M4y09vou4fxON5vjbbH79iAD+1q5XKcC41ZHk4fL5qBV8y0f08gI6V8c9AQPFT X-Received: by 10.28.143.11 with SMTP id r11mr50646521wmd.28.1449131131763; Thu, 03 Dec 2015 00:25:31 -0800 (PST) Received: from localhost.localdomain ([2.44.149.114]) by smtp.gmail.com with ESMTPSA id u4sm6407866wjz.4.2015.12.03.00.25.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 03 Dec 2015 00:25:31 -0800 (PST) From: Ard Biesheuvel To: linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, christoffer.dall@linaro.org, p.fedin@samsung.com Subject: [PATCH v2] ARM/arm64: KVM: correct PTE uncachedness check Date: Thu, 3 Dec 2015 09:25:22 +0100 Message-Id: <1449131122-29186-1-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 1.9.1 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20151203_002553_791510_92EDDC96 X-CRM114-Status: GOOD ( 14.30 ) X-Spam-Score: -2.6 (--) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-2.6 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [2a00:1450:400c:c09:0:0:0:235 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ard Biesheuvel MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org Commit e6fab5442345 ("ARM/arm64: KVM: test properly for a PTE's uncachedness") modified the logic to test whether a HYP or stage-2 mapping needs flushing, from [incorrectly] interpreting the page table attributes to [incorrectly] checking whether the PFN that backs the mapping is covered by host system RAM. The PFN number is part of the output of the translation, not the input, so we have to use pte_pfn() on the contents of the PTE, not __phys_to_pfn() on the HYP virtual address or stage-2 intermediate physical address. Fixes: e6fab5442345 ("ARM/arm64: KVM: test properly for a PTE's uncachedness") Signed-off-by: Ard Biesheuvel --- arch/arm/kvm/mmu.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) -- 1.9.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel diff --git a/arch/arm/kvm/mmu.c b/arch/arm/kvm/mmu.c index 7dace909d5cf..61d96a645ff3 100644 --- a/arch/arm/kvm/mmu.c +++ b/arch/arm/kvm/mmu.c @@ -218,7 +218,7 @@ static void unmap_ptes(struct kvm *kvm, pmd_t *pmd, kvm_tlb_flush_vmid_ipa(kvm, addr); /* No need to invalidate the cache for device mappings */ - if (!kvm_is_device_pfn(__phys_to_pfn(addr))) + if (!kvm_is_device_pfn(pte_pfn(old_pte))) kvm_flush_dcache_pte(old_pte); put_page(virt_to_page(pte)); @@ -310,7 +310,7 @@ static void stage2_flush_ptes(struct kvm *kvm, pmd_t *pmd, pte = pte_offset_kernel(pmd, addr); do { - if (!pte_none(*pte) && !kvm_is_device_pfn(__phys_to_pfn(addr))) + if (!pte_none(*pte) && !kvm_is_device_pfn(pte_pfn(*pte))) kvm_flush_dcache_pte(*pte); } while (pte++, addr += PAGE_SIZE, addr != end); }