All of lore.kernel.org
 help / color / mirror / Atom feed
From: Julien Grall <julien.grall@linaro.org>
To: Stefano Stabellini <sstabellini@kernel.org>
Cc: Andrew Cooper <andrew.cooper3@citrix.com>,
	andre.przywara@linaro.org, xen-devel@lists.xen.org
Subject: Re: [PATCH for-next 07/16] xen/arm: Introduce copy_to_guest_phys_flush_dcache
Date: Fri, 8 Dec 2017 15:34:41 +0000	[thread overview]
Message-ID: <eb938716-6245-ee7e-d7ca-6125930a608a@linaro.org> (raw)
In-Reply-To: <618be515-102f-8368-45f2-622a07066880@linaro.org>

Hi,

On 06/12/17 12:27, Julien Grall wrote:
> On 12/06/2017 01:26 AM, Stefano Stabellini wrote:
>> On Thu, 23 Nov 2017, Julien Grall wrote:
>>> Hi Andrew,
>>>
>>> On 23/11/17 18:49, Andrew Cooper wrote:
>>>> On 23/11/17 18:32, Julien Grall wrote:
>>>>> This new function will be used in a follow-up patch to copy data to 
>>>>> the
>>>>> guest
>>>>> using the IPA (aka guest physical address) and then clean the cache.
>>>>>
>>>>> Signed-off-by: Julien Grall <julien.grall@linaro.org>
>>>>> ---
>>>>>    xen/arch/arm/guestcopy.c           | 10 ++++++++++
>>>>>    xen/include/asm-arm/guest_access.h |  6 ++++++
>>>>>    2 files changed, 16 insertions(+)
>>>>>
>>>>> diff --git a/xen/arch/arm/guestcopy.c b/xen/arch/arm/guestcopy.c
>>>>> index be53bee559..7958663970 100644
>>>>> --- a/xen/arch/arm/guestcopy.c
>>>>> +++ b/xen/arch/arm/guestcopy.c
>>>>> @@ -110,6 +110,16 @@ unsigned long raw_copy_from_guest(void *to, const
>>>>> void __user *from, unsigned le
>>>>>                          COPY_from_guest | COPY_linear);
>>>>>    }
>>>>>    +unsigned long copy_to_guest_phys_flush_dcache(struct domain *d,
>>>>> +                                              paddr_t gpa,
>>>>> +                                              void *buf,
>>>>> +                                              unsigned int len)
>>>>> +{
>>>>> +    /* P2M is shared between all vCPUs, so the vCPU used does not 
>>>>> matter.
>>>>> */
>>>>
>>>> Be very careful with this line of thinking.  It is only works after
>>>> DOMCTL_max_vcpus has succeeded, and before that point, it is a latent
>>>> NULL pointer dereference.
>>>
>>> I really don't expect that function been used before DOMCT_max_vcpus 
>>> is set.
>>> It is only used for hardware emulation or Xen loading image into the 
>>> hardware
>>> domain memory. I could add a check d->vcpus to be safe.
>>>
>>>>
>>>> Also, what about vcpus configured with alternative views?
>>>
>>> It is not important because the underlying call is get_page_from_gfn 
>>> that does
>>> not care about the alternative view (that function take a domain in
>>> parameter). I can update the comment.
>> Since this is a new function, would it make sense to take a struct
>> vcpu* as parameter, instead of a struct domain* ?
> 
> Well, I suggested this patch this way because likely everyone will use 
> with d->vcpus[0]. And then you would have to wonder why d->vcpus[0] and 
> not d->vcpus[1]...

Thinking a bit more to this, it might be better/safer to pass either a 
domain or a vCPU to copy_guest. I can see 2 solutions:
	1# Introduce a union that use the same parameter:
		union
		{
			struct
			{
				struct domain *d;
			} ipa;
			struct
			{
				struct vcpu *v;
			} gva;
		}
	  The structure here would be to ensure that it is clear that only 
domain (resp. vcpu) should be used with ipa (resp. gva).

	2# Have 2 parameters, vcpu and domain.

Any opinions?

Cheers,

-- 
Julien Grall

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

  reply	other threads:[~2017-12-08 15:34 UTC|newest]

Thread overview: 49+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-23 18:31 [PATCH for-next 00/16] xen/arm: Stage-2 handling cleanup Julien Grall
2017-11-23 18:31 ` [PATCH for-next 01/16] xen/arm: raw_copy_to_guest_helper: Rename flush_dcache to flags Julien Grall
2017-12-06  0:51   ` Stefano Stabellini
2017-11-23 18:31 ` [PATCH for-next 02/16] xen/arm: raw_copy_to_guest_helper: Rework the prototype and rename it Julien Grall
2017-12-06  1:04   ` Stefano Stabellini
2017-11-23 18:31 ` [PATCH for-next 03/16] xen/arm: Extend copy_to_guest to support copying from guest VA and use it Julien Grall
2017-12-06  1:05   ` Stefano Stabellini
2017-11-23 18:31 ` [PATCH for-next 04/16] xen/arm: Extend copy_to_guest to support zeroing " Julien Grall
2017-12-06  1:08   ` Stefano Stabellini
2017-11-23 18:31 ` [PATCH for-next 05/16] xen/arm: guest_copy: Extend the prototype to pass the vCPU Julien Grall
2017-12-06  1:11   ` Stefano Stabellini
2017-11-23 18:32 ` [PATCH for-next 06/16] xen/arm: Extend copy_to_guest to support copying from/to guest physical address Julien Grall
2017-12-06  1:22   ` Stefano Stabellini
2017-12-06  1:24     ` Stefano Stabellini
2017-12-06 12:22     ` Julien Grall
2017-12-07 23:01       ` Stefano Stabellini
2017-12-08 15:24         ` Julien Grall
2017-12-08 21:13           ` Stefano Stabellini
2017-11-23 18:32 ` [PATCH for-next 07/16] xen/arm: Introduce copy_to_guest_phys_flush_dcache Julien Grall
2017-11-23 18:49   ` Andrew Cooper
2017-11-23 19:02     ` Julien Grall
2017-12-06  1:26       ` Stefano Stabellini
2017-12-06 12:27         ` Julien Grall
2017-12-08 15:34           ` Julien Grall [this message]
2017-12-08 22:26             ` Stefano Stabellini
2017-12-08 22:30               ` Julien Grall
2017-12-08 22:43                 ` Stefano Stabellini
2017-12-12  0:16                   ` Julien Grall
2017-12-12  0:28                     ` Stefano Stabellini
2017-11-23 18:32 ` [PATCH for-next 08/16] xen/arm: kernel: Rework kernel_zimage_load to use the generic copy helper Julien Grall
2017-12-06  1:38   ` Stefano Stabellini
2017-12-06  1:42     ` Stefano Stabellini
2017-11-23 18:32 ` [PATCH for-next 09/16] xen/arm: domain_build: Rework initrd_load " Julien Grall
2017-12-06  1:56   ` Stefano Stabellini
2017-11-23 18:32 ` [PATCH for-next 10/16] xen/arm: domain_build: Use copy_to_guest_phys_flush_dcache in dtb_load Julien Grall
2017-12-06  1:59   ` Stefano Stabellini
2017-11-23 18:32 ` [PATCH for-next 11/16] xen/arm: p2m: Rename p2m_flush_tlb and p2m_flush_tlb_sync Julien Grall
2017-12-07 22:10   ` Stefano Stabellini
2017-11-23 18:32 ` [PATCH for-next 12/16] xen/arm: p2m: Introduce p2m_tlb_flush_sync, export it and use it Julien Grall
2017-12-07 22:14   ` Stefano Stabellini
2017-11-23 18:32 ` [PATCH for-next 13/16] xen/arm: p2m: Fold p2m_tlb_flush into p2m_force_tlb_flush_sync Julien Grall
2017-12-07 22:26   ` Stefano Stabellini
2017-11-23 18:32 ` [PATCH for-next 14/16] xen/arm: traps: Remove the field gva from mmio_info_t Julien Grall
2017-12-07 22:29   ` Stefano Stabellini
2017-11-23 18:32 ` [PATCH for-next 15/16] xen/arm: traps: Move the definition of mmio_info_t in try_handle_mmio Julien Grall
2017-12-07 22:43   ` Stefano Stabellini
2017-11-23 18:32 ` [PATCH for-next 16/16] xen/arm: traps: Merge do_trap_instr_abort_guest and do_trap_data_abort_guest Julien Grall
2017-12-07 22:43   ` Stefano Stabellini
2017-12-07 22:57     ` Julien Grall

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=eb938716-6245-ee7e-d7ca-6125930a608a@linaro.org \
    --to=julien.grall@linaro.org \
    --cc=andre.przywara@linaro.org \
    --cc=andrew.cooper3@citrix.com \
    --cc=sstabellini@kernel.org \
    --cc=xen-devel@lists.xen.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.