All of lore.kernel.org
 help / color / mirror / Atom feed
From: marc.zyngier@arm.com (Marc Zyngier)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 2/2] ARM: KVM: user_mem_abort: support stage 2 MMIO page mapping
Date: Wed, 07 May 2014 10:00:21 +0100	[thread overview]
Message-ID: <87bnvaotei.fsf@approximate.cambridge.arm.com> (raw)
In-Reply-To: <20140506180448.GH3066@lvm> (Christoffer Dall's message of "Tue, 6 May 2014 19:04:48 +0100")

Kim, Christoffer,

On Tue, May 06 2014 at  7:04:48 pm BST, Christoffer Dall <christoffer.dall@linaro.org> wrote:
> On Tue, Mar 25, 2014 at 05:08:14PM -0500, Kim Phillips wrote:
>> Use the correct memory type for device MMIO mappings: PAGE_S2_DEVICE.
>> 
>> Signed-off-by: Kim Phillips <kim.phillips@linaro.org>
>> ---
>>  arch/arm/kvm/mmu.c | 11 ++++++++---
>>  1 file changed, 8 insertions(+), 3 deletions(-)
>> 
>> diff --git a/arch/arm/kvm/mmu.c b/arch/arm/kvm/mmu.c
>> index 7789857..a354610 100644
>> --- a/arch/arm/kvm/mmu.c
>> +++ b/arch/arm/kvm/mmu.c
>> @@ -652,6 +652,7 @@ static int user_mem_abort(struct kvm_vcpu *vcpu, phys_addr_t fault_ipa,
>>  	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) {
>> @@ -702,6 +703,9 @@ static int user_mem_abort(struct kvm_vcpu *vcpu, phys_addr_t fault_ipa,
>>  	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;
>> @@ -709,7 +713,7 @@ static int user_mem_abort(struct kvm_vcpu *vcpu, phys_addr_t fault_ipa,
>>  		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);
>> @@ -718,13 +722,14 @@ static int user_mem_abort(struct kvm_vcpu *vcpu, phys_addr_t fault_ipa,
>>  		coherent_icache_guest_page(kvm, 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_icache_guest_page(kvm, 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);
>>  	}
>>  
>>  
>> -- 
>> 1.9.1
>> 
>
> I think this looks reasonable.
>
> Acked-by: Christoffer Dall <christoffer.dall@linaro.org>

I feel like I'm missing some context here, and the commit message is way
too terse for me to make sense of it.

So far, we can only get into user_mem_abort on a Stage-2 fault
(translation or permission) for memory. How can we suddenly get here for
a *device* fault? Do we get a special kind of memslot?

I'm not saying the patch does anything wrong, but I'd like to understand
the rationale behind it. On its own, it doesn't make much sense.

Thanks,

        M.
-- 
Jazz is not dead. It just smells funny.

WARNING: multiple messages have this Message-ID (diff)
From: Marc Zyngier <marc.zyngier@arm.com>
To: Christoffer Dall <christoffer.dall@linaro.org>
Cc: Kim Phillips <kim.phillips@linaro.org>,
	"kvmarm\@lists.cs.columbia.edu" <kvmarm@lists.cs.columbia.edu>,
	"linux-arm-kernel\@lists.infradead.org"
	<linux-arm-kernel@lists.infradead.org>,
	"kvm\@vger.kernel.org" <kvm@vger.kernel.org>,
	"linux-kernel\@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	Eric Auger <eric.auger@linaro.org>,
	Alex Williamson <alex.williamson@redhat.com>,
	Antonios Motakis <a.motakis@virtualopensystems.com>,
	Kim Phillips <kim.phillips@freescale.com>
Subject: Re: [PATCH 2/2] ARM: KVM: user_mem_abort: support stage 2 MMIO page mapping
Date: Wed, 07 May 2014 10:00:21 +0100	[thread overview]
Message-ID: <87bnvaotei.fsf@approximate.cambridge.arm.com> (raw)
In-Reply-To: <20140506180448.GH3066@lvm> (Christoffer Dall's message of "Tue, 6 May 2014 19:04:48 +0100")

Kim, Christoffer,

On Tue, May 06 2014 at  7:04:48 pm BST, Christoffer Dall <christoffer.dall@linaro.org> wrote:
> On Tue, Mar 25, 2014 at 05:08:14PM -0500, Kim Phillips wrote:
>> Use the correct memory type for device MMIO mappings: PAGE_S2_DEVICE.
>> 
>> Signed-off-by: Kim Phillips <kim.phillips@linaro.org>
>> ---
>>  arch/arm/kvm/mmu.c | 11 ++++++++---
>>  1 file changed, 8 insertions(+), 3 deletions(-)
>> 
>> diff --git a/arch/arm/kvm/mmu.c b/arch/arm/kvm/mmu.c
>> index 7789857..a354610 100644
>> --- a/arch/arm/kvm/mmu.c
>> +++ b/arch/arm/kvm/mmu.c
>> @@ -652,6 +652,7 @@ static int user_mem_abort(struct kvm_vcpu *vcpu, phys_addr_t fault_ipa,
>>  	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) {
>> @@ -702,6 +703,9 @@ static int user_mem_abort(struct kvm_vcpu *vcpu, phys_addr_t fault_ipa,
>>  	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;
>> @@ -709,7 +713,7 @@ static int user_mem_abort(struct kvm_vcpu *vcpu, phys_addr_t fault_ipa,
>>  		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);
>> @@ -718,13 +722,14 @@ static int user_mem_abort(struct kvm_vcpu *vcpu, phys_addr_t fault_ipa,
>>  		coherent_icache_guest_page(kvm, 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_icache_guest_page(kvm, 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);
>>  	}
>>  
>>  
>> -- 
>> 1.9.1
>> 
>
> I think this looks reasonable.
>
> Acked-by: Christoffer Dall <christoffer.dall@linaro.org>

I feel like I'm missing some context here, and the commit message is way
too terse for me to make sense of it.

So far, we can only get into user_mem_abort on a Stage-2 fault
(translation or permission) for memory. How can we suddenly get here for
a *device* fault? Do we get a special kind of memslot?

I'm not saying the patch does anything wrong, but I'd like to understand
the rationale behind it. On its own, it doesn't make much sense.

Thanks,

        M.
-- 
Jazz is not dead. It just smells funny.

  reply	other threads:[~2014-05-07  9:00 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-03-25 22:08 [PATCH 1/2] ARM: KVM: Enable the KVM-VFIO device Kim Phillips
2014-03-25 22:08 ` Kim Phillips
2014-03-25 22:08 ` [PATCH 2/2] ARM: KVM: user_mem_abort: support stage 2 MMIO page mapping Kim Phillips
2014-03-25 22:08   ` Kim Phillips
2014-05-06 18:04   ` Christoffer Dall
2014-05-06 18:04     ` Christoffer Dall
2014-05-07  9:00     ` Marc Zyngier [this message]
2014-05-07  9:00       ` Marc Zyngier
2014-05-07 14:55       ` Christoffer Dall
2014-05-07 14:55         ` Christoffer Dall
2014-06-24 10:23         ` Will Deacon
2014-06-24 10:23           ` Will Deacon
2014-06-24 10:39           ` Marc Zyngier
2014-06-24 10:39             ` Marc Zyngier
2014-06-26  0:45             ` [PATCH 2/2 v2] " Kim Phillips
2014-06-26  0:45               ` Kim Phillips
2014-06-26  0:45               ` Kim Phillips
2014-06-26  8:46               ` Will Deacon
2014-06-26  8:46                 ` Will Deacon
2014-06-30  9:08                 ` Christoffer Dall
2014-06-30  9:08                   ` Christoffer Dall
2014-06-30  9:14                   ` Marc Zyngier
2014-06-30  9:14                     ` Marc Zyngier

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=87bnvaotei.fsf@approximate.cambridge.arm.com \
    --to=marc.zyngier@arm.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.