linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Vincent Donnefort <vdonnefort@google.com>
To: Quentin Perret <qperret@google.com>
Cc: maz@kernel.org, oliver.upton@linux.dev, joey.gouly@arm.com,
	suzuki.poulose@arm.com, yuzenghui@huawei.com,
	catalin.marinas@arm.com, will@kernel.org,
	linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev,
	linux-kernel@vger.kernel.org, kernel-team@android.com
Subject: Re: [PATCH 2/9] KVM: arm64: Add a range to __pkvm_host_share_guest()
Date: Mon, 3 Mar 2025 09:03:09 +0000	[thread overview]
Message-ID: <Z8VwTf8nMvRNjgU_@google.com> (raw)
In-Reply-To: <Z8IJRpoQUoGazLku@google.com>

On Fri, Feb 28, 2025 at 07:06:46PM +0000, Quentin Perret wrote:
> On Friday 28 Feb 2025 at 10:25:18 (+0000), Vincent Donnefort wrote:
> > +int __pkvm_host_share_guest(u64 pfn, u64 gfn, u64 nr_pages, struct pkvm_hyp_vcpu *vcpu,
> >  			    enum kvm_pgtable_prot prot)
> >  {
> >  	struct pkvm_hyp_vm *vm = pkvm_hyp_vcpu_to_hyp_vm(vcpu);
> >  	u64 phys = hyp_pfn_to_phys(pfn);
> >  	u64 ipa = hyp_pfn_to_phys(gfn);
> >  	struct hyp_page *page;
> > +	u64 size;
> >  	int ret;
> >  
> >  	if (prot & ~KVM_PGTABLE_PROT_RWX)
> >  		return -EINVAL;
> >  
> > -	ret = check_range_allowed_memory(phys, phys + PAGE_SIZE);
> 
> I'm not sure it is safe to drop this check here, see below.
> 
> > +	ret = __guest_check_transition_size(phys, ipa, nr_pages, &size);
> >  	if (ret)
> >  		return ret;
> >  
> >  	host_lock_component();
> >  	guest_lock_component(vm);
> >  
> > -	ret = __guest_check_page_state_range(vcpu, ipa, PAGE_SIZE, PKVM_NOPAGE);
> > +	ret = __guest_check_page_state_range(vm, ipa, size, PKVM_NOPAGE);
> >  	if (ret)
> >  		goto unlock;
> >  
> >  	page = hyp_phys_to_page(phys);
> 
> Phys really needs to be a valid memory address here for 'page' to be
> present in the vmemma -- dereference right below. So we can't rely on
> the check in __host_check_page_state_range() sadly ...

Haaa you're right. Sad to have this double check. Perhaps I won't use
__host_check_page_state_range() then.

> 
> > +	ret = __host_check_page_state_range(phys, size, page->host_state);
> > +	if (ret)
> > +		goto unlock;
> > +

[...]


  reply	other threads:[~2025-03-03  9:05 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-28 10:25 [PATCH 0/9] Stage-2 huge mappings for pKVM np-guests Vincent Donnefort
2025-02-28 10:25 ` [PATCH 1/9] KVM: arm64: Handle huge mappings for np-guest CMOs Vincent Donnefort
2025-02-28 18:54   ` Quentin Perret
2025-03-03  9:08     ` Vincent Donnefort
2025-02-28 10:25 ` [PATCH 2/9] KVM: arm64: Add a range to __pkvm_host_share_guest() Vincent Donnefort
2025-02-28 19:06   ` Quentin Perret
2025-03-03  9:03     ` Vincent Donnefort [this message]
2025-02-28 10:25 ` [PATCH 2/9] KVM: arm64: Add " Vincent Donnefort
2025-02-28 10:25 ` [PATCH 3/9] KVM: arm64: Add a range to __pkvm_host_unshare_guest() Vincent Donnefort
2025-02-28 10:25 ` [PATCH 3/9] KVM: arm64: Add " Vincent Donnefort
2025-02-28 10:25 ` [PATCH 4/9] KVM: arm64: Add a range to __pkvm_host_wrprotect_guest() Vincent Donnefort
2025-02-28 10:25 ` [PATCH 4/9] KVM: arm64: Add " Vincent Donnefort
2025-02-28 10:25 ` [PATCH 5/9] KVM: arm64: Add a range to __pkvm_host_test_clear_young_guest() Vincent Donnefort
2025-02-28 10:25 ` [PATCH 5/9] KVM: arm64: Add " Vincent Donnefort
2025-02-28 10:25 ` [PATCH 6/9] KVM: arm64: Convert pkvm_mappings to interval tree Vincent Donnefort
2025-02-28 10:25 ` [PATCH 7/9] KVM: arm64: Add a range to pkvm_mappings Vincent Donnefort
2025-02-28 10:25 ` [PATCH 7/9] KVM: arm64: Add " Vincent Donnefort
2025-02-28 10:25 ` [PATCH 8/9] KVM: arm64: Stage-2 huge mappings for np-guests Vincent Donnefort
2025-02-28 10:25 ` [PATCH 9/9] KVM: arm64: np-guest CMOs with PMD_SIZE fixmap Vincent Donnefort

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=Z8VwTf8nMvRNjgU_@google.com \
    --to=vdonnefort@google.com \
    --cc=catalin.marinas@arm.com \
    --cc=joey.gouly@arm.com \
    --cc=kernel-team@android.com \
    --cc=kvmarm@lists.linux.dev \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maz@kernel.org \
    --cc=oliver.upton@linux.dev \
    --cc=qperret@google.com \
    --cc=suzuki.poulose@arm.com \
    --cc=will@kernel.org \
    --cc=yuzenghui@huawei.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).