xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Jiageng Yu <yujiageng734@gmail.com>
To: Tim Deegan <tim@xen.org>
Cc: "xen-devel@lists.xensource.com" <xen-devel@lists.xensource.com>,
	Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>,
	Stefano Stabellini <stefano.stabellini@eu.citrix.com>,
	Ian Campbell <Ian.Campbell@eu.citrix.com>,
	Keir Fraser <keir.xen@gmail.com>,
	Anthony PERARD <anthony.perard@gmail.com>,
	Thibault <samuel.thibault@ens-lyon.org>
Subject: Re: Re: Linux Stubdom Problem
Date: Fri, 2 Sep 2011 10:32:18 +0800	[thread overview]
Message-ID: <CAJ0pt14GRw9mvR6YpgD+svoRAL=pO9ki5jdp0XfHCcdebQ9ahA@mail.gmail.com> (raw)
In-Reply-To: <20110901172728.GH3859@ocelot.phlegethon.org>

2011/9/2 Tim Deegan <tim@xen.org>:
> At 01:12 +0800 on 02 Sep (1314925970), Jiageng Yu wrote:
>> 2011/8/31 Keir Fraser <keir.xen@gmail.com>:
>> > On 29/08/2011 17:03, "Stefano Stabellini" <stefano.stabellini@eu.citrix.com>
>> > wrote:
>> >
>> >>> Oh, so it will.  You'd need to arrange for that to be called from inside
>> >>> the guest; or you could implement an add_to_physmap space for it; that
>> >>> could be called from another domain.
>> >>
>> >> "From inside the guest" means hvmloader?
>> >> The good thing about doing it in hvmloader is that we could use the
>> >> traditional PV frontend/backend mechanism to share pages. On the other
>> >> hand hvmloader doesn't know if we are using stubdoms at the moment and
>> >> it would need to issue the grant table hypercall only in that case.
>> >> Unless we decide to always grant the videoram to guests but it would
>> >> change once again the domain to which the videoram is accounted for
>> >> (dom0/stubdom rather than the guest, that is a bad thing).
>> >> Also I don't like the idea of making hvmloader stubdom aware.
>> >
>> > I don't see a problem with it, in principle. I see hvmloader as almost an
>> > in-guest part of the toolstack. The fact that it only executes at guest boot
>> > means it can be fairly closely tied to the toolstack version.
>> >
>> >  -- Keir
>> >
>> >
>> >
>>
>> Hi all,
>>
>>     I report a new issue about vram mapping in linux stubdom. I use
>> the follow patch to map the mfn of stubdom into hvm guest.
>>
>> diff -r 0f36c2eec2e1 xen/arch/x86/mm.c
>> --- a/xen/arch/x86/mm.c       Thu Jul 28 15:40:54 2011 +0100
>> +++ b/xen/arch/x86/mm.c       Thu Sep 01 14:52:25 2011 +0100
>> @@ -4663,6 +4665,14 @@
>>              page = mfn_to_page(mfn);
>>              break;
>>          }
>> +       case XENMAPSPACE_mfn:
>> +       {
>> +             if(!IS_PRIV_FOR(current->domain, d))
>> +                     return -EINVAL;
>> +             mfn = xatp.idx;
>> +             page = mfn_to_page(mfn);
>> +             break;
>> +       }
>
> I would really rather not have this interface; I don't see why we can't
> use grant tables for this.
>

Hi,

    In linux based stubdom case, we want to keep hvm guest and its
hvmloader unaware of running on stubdom. Therefore, we do need a way
to map vram pages of stubdom into guest hvm transparently.

   If we use the grant tables for this, the general procedure would be:

   1.  stubdom allocates vram pages
   2.  stubdom creates the grant reference for these pages and
transfers the GRs to hvm guest(or hvmloader)
   3.  hvm guest(or hvmloader) maps these pages into its memory space
using the GRs
   4.  stubdom and hvm guest share the same vram memory.

   In this procedure, the hvm guest(or hvmloader) must know it is
running on stubdom.

   Additionally, if I modified grant table to map pages without any
participation of hvm guest(or hvmloader), it will obey the design
goals of grant table. So I think grant table may not be suitable for
our case.

   Another idea is to allocate vram in hvm guest and stubdom maps vram
pages into its memory space. In this scenario, I must delay the
initial process of xen-fbfront in stubdom until qemu populates vram
pages for hvm guest (unsing xc_domain_populate_physmap_exact()). Then,
I map these pages into stubdom kernel through the function similar to
privcmd_ioctl_mmap_batch(). But I would not use privcmd device.

   If anyone has any advice for me I'm all ears.

   Thanks.

Jiageng Yu.

> If you must do it this way, it should check that the MFN is valid and
> that it's owned by the caller.
>
>>          default:
>>              break;
>>          }
>> @@ -4693,13 +4708,17 @@
>>          }
>>
>>          /* Unmap from old location, if any. */
>> -        gpfn = get_gpfn_from_mfn(mfn);
>> -        ASSERT( gpfn != SHARED_M2P_ENTRY );
>> -        if ( gpfn != INVALID_M2P_ENTRY )
>> -            guest_physmap_remove_page(d, gpfn, mfn, 0);
>> +      if(xatp.space!=XENMAPSPACE_mfn) {
>> +           gpfn = get_gpfn_from_mfn(mfn);
>> +           ASSERT( gpfn != SHARED_M2P_ENTRY );
>> +           if ( gpfn != INVALID_M2P_ENTRY )
>> +               guest_physmap_remove_page(d, gpfn, mfn, 0);
>> +      }
>
> Why did you make this change?
>
>>
>>          /* Map at new location. */
>>          rc = guest_physmap_add_page(d, xatp.gpfn, mfn, 0);
>> diff -r 0f36c2eec2e1 xen/include/public/memory.h
>> --- a/xen/include/public/memory.h     Thu Jul 28 15:40:54 2011 +0100
>> +++ b/xen/include/public/memory.h     Thu Sep 01 14:52:25 2011 +0100
>> @@ -212,6 +212,7 @@
>>  #define XENMAPSPACE_shared_info 0 /* shared info page */
>>  #define XENMAPSPACE_grant_table 1 /* grant table page */
>>  #define XENMAPSPACE_gmfn        2 /* GMFN */
>> +#define XENMAPSPACE_mfn          3 /* MFN  */
>>      unsigned int space;
>>
>>  #define XENMAPIDX_grant_table_status 0x80000000
>>
>>
>> I got error at:
>>
>> arch_memory_op()
>>    -->case XENMEM_add_to_physmap:
>>          -->if ( page )
>>               -->put_page(page);
>>                     -->free_domheap_page(page);
>>                            -->BUG_ON((pg[i].u.inuse.type_info &
>> PGT_count_mask) != 0);
>>
>> In my case, pg[i].u.inuse.type_info & PGT_count_mask =1.
>
> OK, so you've dropped the last untyped refcount on a page which still
> has a type count.  That means the reference counting has got messed up
> somewhere.
>
>> Actually, in the linux based stubdom case, I need to keep these pages
>> of vram mapped in qemu of stubdom. But it seems that granting pages
>> implies having the pages unmapped in the process that grants them.
>> Maybe the grant table could not solve the vram mapping problem.
>
> But this patch doesn't use the grant tables at all.
>
> Tim.
>
> --
>

  reply	other threads:[~2011-09-02  2:32 UTC|newest]

Thread overview: 52+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-07-21 16:54 Linux Stubdom Problem Jiageng Yu
2011-07-21 17:08 ` iommu=force-hpdl385g7 boot option as workaround for missing IOMMU support in BIOS of HP DL385 g7 Mark Schneider
2011-07-21 17:18 ` Linux Stubdom Problem Stefano Stabellini
2011-07-25 16:45   ` Jiageng Yu
2011-07-26 17:50     ` Jiageng Yu
2011-07-27 11:26       ` Stefano Stabellini
2011-07-27 12:56         ` Jiageng Yu
2011-07-27 13:34           ` Stefano Stabellini
2011-07-28 15:34             ` Jiageng Yu
2011-07-28 17:01               ` Jiageng Yu
2011-07-29 14:29                 ` Stefano Stabellini
2011-07-29 14:51                   ` Jiageng Yu
2011-07-29 15:04                     ` Stefano Stabellini
2011-07-29 15:09                       ` Jiageng Yu
2011-07-29 15:18                         ` Stefano Stabellini
2011-07-29 15:16                           ` Jiageng Yu
2011-07-29 15:28                             ` Stefano Stabellini
2011-08-12 16:22                               ` Jiageng Yu
2011-08-15 12:46                                 ` Jiageng Yu
2011-08-18 23:39                                   ` Stefano Stabellini
2011-08-22 15:24                                     ` Jiageng Yu
2011-08-22 19:36                                       ` Stefano Stabellini
2011-08-22 20:16                                         ` Keir Fraser
2011-08-23  9:39                                         ` Jiageng Yu
2011-08-23 14:38                                           ` Stefano Stabellini
2011-08-23 10:07                                         ` Tim Deegan
2011-08-23 12:59                                           ` Stefano Stabellini
2011-08-26 16:12                                             ` Stefano Stabellini
2011-08-27 13:06                                               ` Tim Deegan
2011-08-29 12:27                                                 ` Stefano Stabellini
2011-08-29 13:18                                                   ` Tim Deegan
2011-08-29 16:03                                                     ` Stefano Stabellini
2011-08-31  6:02                                                       ` Keir Fraser
2011-09-01 17:12                                                         ` Jiageng Yu
2011-09-01 17:27                                                           ` Tim Deegan
2011-09-02  2:32                                                             ` Jiageng Yu [this message]
2011-09-02 11:03                                                               ` Tim Deegan
2011-09-02 13:09                                                                 ` Stefano Stabellini
2011-09-02 13:11                                                                   ` Keir Fraser
2011-09-14 13:38                                                                     ` Jiageng Yu
2011-09-15 11:13                                                                       ` Stefano Stabellini
2011-10-27 14:56                                                                         ` Jiageng Yu
2011-11-08 17:05                                                                           ` Stefano Stabellini
2011-11-09  8:59                                                                             ` Jiageng Yu
2011-11-09 13:47                                                                               ` Stefano Stabellini
2011-11-09 14:30                                                                                 ` Jiageng Yu
2011-11-10 10:19                                                                                   ` Stefano Stabellini
2011-11-17 15:18                                                                                     ` Jiageng Yu
2011-11-18 11:21                                                                                       ` Stefano Stabellini
2011-11-09 17:05                                                                             ` Konrad Rzeszutek Wilk
2011-11-10 10:10                                                                               ` Stefano Stabellini
2011-11-04 14:00                                                                         ` Jiageng Yu

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='CAJ0pt14GRw9mvR6YpgD+svoRAL=pO9ki5jdp0XfHCcdebQ9ahA@mail.gmail.com' \
    --to=yujiageng734@gmail.com \
    --cc=Ian.Campbell@eu.citrix.com \
    --cc=anthony.perard@gmail.com \
    --cc=keir.xen@gmail.com \
    --cc=konrad.wilk@oracle.com \
    --cc=samuel.thibault@ens-lyon.org \
    --cc=stefano.stabellini@eu.citrix.com \
    --cc=tim@xen.org \
    --cc=xen-devel@lists.xensource.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).