From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
stable@vger.kernel.org, Kim Phillips <kim.phillips@linaro.org>,
Christoffer Dall <christoffer.dall@linaro.org>,
Will Deacon <will.deacon@arm.com>,
Marc Zyngier <marc.zyngier@arm.com>,
Shannon Zhao <shannon.zhao@linaro.org>
Subject: [PATCH 3.14 10/17] ARM: KVM: user_mem_abort: support stage 2 MMIO page mapping
Date: Fri, 26 Jun 2015 18:08:32 -0700 [thread overview]
Message-ID: <20150627010820.543034067@linuxfoundation.org> (raw)
In-Reply-To: <20150627010820.231673616@linuxfoundation.org>
3.14-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kim Phillips <kim.phillips@linaro.org>
commit b88657674d39fc2127d62d0de9ca142e166443c8 upstream.
A userspace process can map device MMIO memory via VFIO or /dev/mem,
e.g., for platform device passthrough support in QEMU.
During early development, we found the PAGE_S2 memory type being used
for MMIO mappings. This patch corrects that by using the more strongly
ordered memory type for device MMIO mappings: PAGE_S2_DEVICE.
Signed-off-by: Kim Phillips <kim.phillips@linaro.org>
Acked-by: Christoffer Dall <christoffer.dall@linaro.org>
Acked-by: Will Deacon <will.deacon@arm.com>
Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
arch/arm/kvm/mmu.c | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
--- a/arch/arm/kvm/mmu.c
+++ b/arch/arm/kvm/mmu.c
@@ -759,6 +759,7 @@ static int user_mem_abort(struct kvm_vcp
struct kvm_mmu_memory_cache *memcache = &vcpu->arch.mmu_page_cache;
struct vm_area_struct *vma;
pfn_t pfn;
+ pgprot_t mem_type = PAGE_S2;
write_fault = kvm_is_write_fault(kvm_vcpu_get_hsr(vcpu));
if (fault_status == FSC_PERM && !write_fault) {
@@ -809,6 +810,9 @@ static int user_mem_abort(struct kvm_vcp
if (is_error_pfn(pfn))
return -EFAULT;
+ if (kvm_is_mmio_pfn(pfn))
+ mem_type = PAGE_S2_DEVICE;
+
spin_lock(&kvm->mmu_lock);
if (mmu_notifier_retry(kvm, mmu_seq))
goto out_unlock;
@@ -816,7 +820,7 @@ static int user_mem_abort(struct kvm_vcp
hugetlb = transparent_hugepage_adjust(&pfn, &fault_ipa);
if (hugetlb) {
- pmd_t new_pmd = pfn_pmd(pfn, PAGE_S2);
+ pmd_t new_pmd = pfn_pmd(pfn, mem_type);
new_pmd = pmd_mkhuge(new_pmd);
if (writable) {
kvm_set_s2pmd_writable(&new_pmd);
@@ -825,13 +829,14 @@ static int user_mem_abort(struct kvm_vcp
coherent_cache_guest_page(vcpu, hva & PMD_MASK, PMD_SIZE);
ret = stage2_set_pmd_huge(kvm, memcache, fault_ipa, &new_pmd);
} else {
- pte_t new_pte = pfn_pte(pfn, PAGE_S2);
+ pte_t new_pte = pfn_pte(pfn, mem_type);
if (writable) {
kvm_set_s2pte_writable(&new_pte);
kvm_set_pfn_dirty(pfn);
}
coherent_cache_guest_page(vcpu, hva, PAGE_SIZE);
- ret = stage2_set_pte(kvm, memcache, fault_ipa, &new_pte, false);
+ ret = stage2_set_pte(kvm, memcache, fault_ipa, &new_pte,
+ mem_type == PAGE_S2_DEVICE);
}
next prev parent reply other threads:[~2015-06-27 1:08 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-06-27 1:08 [PATCH 3.14 00/17] 3.14.46-stable review Greg Kroah-Hartman
2015-06-27 1:08 ` [PATCH 3.14 01/17] crypto: caam - fix RNG buffer cache alignment Greg Kroah-Hartman
2015-06-27 1:08 ` [PATCH 3.14 02/17] tracing: Have filter check for balanced ops Greg Kroah-Hartman
2015-06-27 1:08 ` [PATCH 3.14 03/17] drm/mgag200: Reject non-character-cell-aligned mode widths Greg Kroah-Hartman
2015-06-27 1:08 ` [PATCH 3.14 04/17] ath3k: Add support of 0489:e076 AR3012 device Greg Kroah-Hartman
2015-06-27 1:08 ` [PATCH 3.14 05/17] ath3k: add support of 13d3:3474 " Greg Kroah-Hartman
2015-06-27 1:08 ` [PATCH 3.14 06/17] pipe: iovec: Fix memory corruption when retrying atomic copy as non-atomic Greg Kroah-Hartman
2015-06-27 1:08 ` [PATCH 3.14 07/17] lpfc: Add iotag memory barrier Greg Kroah-Hartman
2015-06-27 1:08 ` [PATCH 3.14 08/17] arm/arm64: KVM: Fix and refactor unmap_range Greg Kroah-Hartman
2015-06-27 1:08 ` [PATCH 3.14 09/17] ARM: KVM: Unmap IPA on memslot delete/move Greg Kroah-Hartman
2015-06-27 1:08 ` Greg Kroah-Hartman [this message]
2015-06-27 1:08 ` [PATCH 3.14 12/17] ARM: virt: fix wrong HSCTLR.EE bit setting Greg Kroah-Hartman
2015-06-27 1:08 ` [PATCH 3.14 13/17] ARM64: KVM: store kvm_vcpu_fault_info est_el2 as word Greg Kroah-Hartman
2015-06-27 1:08 ` [PATCH 3.14 14/17] KVM: ARM/arm64: fix non-const declaration of function returning const Greg Kroah-Hartman
2015-06-27 1:08 ` [PATCH 3.14 15/17] KVM: ARM/arm64: fix broken __percpu annotation Greg Kroah-Hartman
2015-06-27 1:08 ` [PATCH 3.14 16/17] KVM: ARM/arm64: avoid returning negative error code as bool Greg Kroah-Hartman
2015-06-27 1:08 ` [PATCH 3.14 17/17] KVM: vgic: return int instead of bool when checking I/O ranges Greg Kroah-Hartman
2015-06-27 3:12 ` [PATCH 3.14 00/17] 3.14.46-stable review Shuah Khan
2015-06-27 5:41 ` Guenter Roeck
2015-06-27 10:15 ` Sudip Mukherjee
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20150627010820.543034067@linuxfoundation.org \
--to=gregkh@linuxfoundation.org \
--cc=christoffer.dall@linaro.org \
--cc=kim.phillips@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=marc.zyngier@arm.com \
--cc=shannon.zhao@linaro.org \
--cc=stable@vger.kernel.org \
--cc=will.deacon@arm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).