From patchwork Thu Dec 3 08:20:57 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 57623 Delivered-To: patch@linaro.org Received: by 10.112.155.196 with SMTP id vy4csp3359028lbb; Thu, 3 Dec 2015 00:22:56 -0800 (PST) X-Received: by 10.98.11.153 with SMTP id 25mr11438674pfl.102.1449130975900; Thu, 03 Dec 2015 00:22:55 -0800 (PST) Return-Path: Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id up8si10547545pac.111.2015.12.03.00.22.55 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 03 Dec 2015 00:22:55 -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 1a4P8u-0003Ju-Pc; Thu, 03 Dec 2015 08:21:32 +0000 Received: from mail-wm0-x231.google.com ([2a00:1450:400c:c09::231]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1a4P8o-00032A-5t for linux-arm-kernel@lists.infradead.org; Thu, 03 Dec 2015 08:21:28 +0000 Received: by wmec201 with SMTP id c201so11350595wme.1 for ; Thu, 03 Dec 2015 00:21:04 -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=NMNGjVjAVDcnbUzDinN41yz0pf6S1J9CM+GgIFnzf6A=; b=mkTJjLxURm+C9Iiouvi+5qqVUom0pm26C//9Bq0iRBlQ0lO2L/vcorlsD3i9asljv3 /KaLK/bPEDbnft+f8pHx5dAU8ImqVdSo3/npFKwd8WiNvDW1hF5VG+QCoStIRu81fbY9 wrRLgMWhF3mb2+I9pNgziY23+0ySQz2pZCA3KBIuWkAG7MOWjg6H6NHG7W40YkRFLTbt B0/9eLGgxa3ffiaFYlxkNawLdJ40UjIcorcKtocS5KBAy5yA2QfwWT1A4+Z7AHxrglw5 gvalHp1H5OcGNLkrJD1fiht855A9sgNsHF4LQaL/JKditseV+KDFPFYDIwWhcKgLHvvj yZ9w== 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=NMNGjVjAVDcnbUzDinN41yz0pf6S1J9CM+GgIFnzf6A=; b=EilkkNRw5y+Cj9e4YJoH65tCh/F+bMdHUVOD9A2rodutELGt+sSGJcv83IDiOwq1wj TX9ESNwlZHMqJeDLrX5JtlWDuQG1qJRPEEpakadFtHXxZK5z59kh7pttZqQr9vS9Z43a JSsCFJA/VNhoK4oRSbFpz8KMJ8hiJisq8M2SRa/Pv3oD95JZZFm0BoZWIuX6cqxZwBGH iSgGeBcVuGWWP906cHKD4hnWskAtjonkRT2+Z8dNepIQF5EWOz42apPPvnu4mi6sKsAy nGdX8tLaanvuhVVxV4girNqw4tVDtdlYtm/gAmMnuDW9GiQdP6eYDgb11m+GxHXc6DFv 1Asg== X-Gm-Message-State: ALoCoQlIEGaNUq2HOG6Xz2yYAI1kwwCuLvcEBN0xoqVxGy7iGVjohuIIgixv4lCU9P5Pe4wJFnGf X-Received: by 10.194.190.225 with SMTP id gt1mr10506685wjc.94.1449130864247; Thu, 03 Dec 2015 00:21:04 -0800 (PST) Received: from localhost.localdomain ([2.44.149.114]) by smtp.gmail.com with ESMTPSA id w203sm34363128wmg.15.2015.12.03.00.21.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 03 Dec 2015 00:21:03 -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] ARM/arm64: KVM: correct PTE uncachedness check Date: Thu, 3 Dec 2015 09:20:57 +0100 Message-Id: <1449130857-21740-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_002126_737482_2A3BCDA5 X-CRM114-Status: GOOD ( 14.20 ) 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:231 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..9708c342795f 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(addr))) 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(addr))) kvm_flush_dcache_pte(*pte); } while (pte++, addr += PAGE_SIZE, addr != end); }