diff mbox series

[v2,18/20] xen/mem_access: Use __get_gfn_type_access in set_mem_access

Message ID d814a518fc201c76ffd8f254c534719ee278175a.1576697796.git.tamas.lengyel@intel.com (mailing list archive)
State Superseded
Headers show
Series VM forking | expand

Commit Message

Tamas K Lengyel Dec. 18, 2019, 7:40 p.m. UTC
Use __get_gfn_type_access instead of p2m->get_entry to trigger page-forking
when the mem_access permission is being set on a page that has not yet been
copied over from the parent.

Signed-off-by: Tamas K Lengyel <tamas.lengyel@intel.com>
---
 xen/arch/x86/mm/mem_access.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

Comments

Alexandru Stefan ISAILA Dec. 19, 2019, 7:59 a.m. UTC | #1
On 18.12.2019 21:40, Tamas K Lengyel wrote:
> Use __get_gfn_type_access instead of p2m->get_entry to trigger page-forking
> when the mem_access permission is being set on a page that has not yet been
> copied over from the parent.
> 
> Signed-off-by: Tamas K Lengyel <tamas.lengyel@intel.comReviewed-by: Alexandru Isaila <aisaila@bitdefender.com>

> ---
>   xen/arch/x86/mm/mem_access.c | 5 ++---
>   1 file changed, 2 insertions(+), 3 deletions(-)
> 
> diff --git a/xen/arch/x86/mm/mem_access.c b/xen/arch/x86/mm/mem_access.c
> index 320b9fe621..9caf08a5b2 100644
> --- a/xen/arch/x86/mm/mem_access.c
> +++ b/xen/arch/x86/mm/mem_access.c
> @@ -303,11 +303,10 @@ static int set_mem_access(struct domain *d, struct p2m_domain *p2m,
>       ASSERT(!ap2m);
>   #endif
>       {
> -        mfn_t mfn;
>           p2m_access_t _a;
>           p2m_type_t t;
> -
> -        mfn = p2m->get_entry(p2m, gfn, &t, &_a, 0, NULL, NULL);
> +        mfn_t mfn = __get_gfn_type_access(p2m, gfn_x(gfn), &t, &_a,
> +                                          P2M_ALLOC, NULL, false);

Don't you want p2m_query_t to be 0 as it was in the p2m->get_entry() call ?

>           rc = p2m->set_entry(p2m, gfn, mfn, PAGE_ORDER_4K, t, a, -1);
>       }
>   
> 

Alex
Tamas K Lengyel Dec. 19, 2019, 4 p.m. UTC | #2
On Thu, Dec 19, 2019 at 12:59 AM Alexandru Stefan ISAILA
<aisaila@bitdefender.com> wrote:
>
>
>
> On 18.12.2019 21:40, Tamas K Lengyel wrote:
> > Use __get_gfn_type_access instead of p2m->get_entry to trigger page-forking
> > when the mem_access permission is being set on a page that has not yet been
> > copied over from the parent.
> >
> > Signed-off-by: Tamas K Lengyel <tamas.lengyel@intel.comReviewed-by: Alexandru Isaila <aisaila@bitdefender.com>
>
> > ---
> >   xen/arch/x86/mm/mem_access.c | 5 ++---
> >   1 file changed, 2 insertions(+), 3 deletions(-)
> >
> > diff --git a/xen/arch/x86/mm/mem_access.c b/xen/arch/x86/mm/mem_access.c
> > index 320b9fe621..9caf08a5b2 100644
> > --- a/xen/arch/x86/mm/mem_access.c
> > +++ b/xen/arch/x86/mm/mem_access.c
> > @@ -303,11 +303,10 @@ static int set_mem_access(struct domain *d, struct p2m_domain *p2m,
> >       ASSERT(!ap2m);
> >   #endif
> >       {
> > -        mfn_t mfn;
> >           p2m_access_t _a;
> >           p2m_type_t t;
> > -
> > -        mfn = p2m->get_entry(p2m, gfn, &t, &_a, 0, NULL, NULL);
> > +        mfn_t mfn = __get_gfn_type_access(p2m, gfn_x(gfn), &t, &_a,
> > +                                          P2M_ALLOC, NULL, false);
>
> Don't you want p2m_query_t to be 0 as it was in the p2m->get_entry() call ?

No, the entire point of the patch is to have the P2M_ALLOC query flag
set. That triggers the fork's p2m population.

Tamas
diff mbox series

Patch

diff --git a/xen/arch/x86/mm/mem_access.c b/xen/arch/x86/mm/mem_access.c
index 320b9fe621..9caf08a5b2 100644
--- a/xen/arch/x86/mm/mem_access.c
+++ b/xen/arch/x86/mm/mem_access.c
@@ -303,11 +303,10 @@  static int set_mem_access(struct domain *d, struct p2m_domain *p2m,
     ASSERT(!ap2m);
 #endif
     {
-        mfn_t mfn;
         p2m_access_t _a;
         p2m_type_t t;
-
-        mfn = p2m->get_entry(p2m, gfn, &t, &_a, 0, NULL, NULL);
+        mfn_t mfn = __get_gfn_type_access(p2m, gfn_x(gfn), &t, &_a,
+                                          P2M_ALLOC, NULL, false);
         rc = p2m->set_entry(p2m, gfn, mfn, PAGE_ORDER_4K, t, a, -1);
     }