From: "Kasai Takanori" Subject: [PATCH] Fix expandable grant table for x86 Date: Wed, 30 May 2007 21:38:29 +0900 Message-ID: <0ca101c7a2b7$721bd510$dab2220a@VF03007L> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_NextPart_000_0C9E_01C7A302.DCFC1AC0" Return-path: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: xen-devel List-Id: xen-devel@lists.xenproject.org This is a multi-part message in MIME format. ------=_NextPart_000_0C9E_01C7A302.DCFC1AC0 Content-Type: text/plain; format=flowed; charset="iso-2022-jp"; reply-type=original Content-Transfer-Encoding: 7bit Hi All, We contributed this problem that the grant table was not able to be expanded before. We corrected that HYPERCALL of grant_table_op was able to be called from the HVM domain with x86. It was confirmed to be able to expand grant table by this patch. It is not tested things except the acquisition of the query size. It seems that the structure of HYPERCALL is the same excluding GNTTABOP_setup_table as 32 bits and 64 bits. When it was not hvm domain, GNTTABOP_setup_table returned ENOSYS. Signed-off-by: Takanori Kasai Signed-off-by: Tsunehisa Doi Best Regards, -- Takanori Kasai ----- Original Message ----- From: "Kasai Takanori" To: "xen-devel" Sent: Thursday, May 24, 2007 8:50 PM Subject: [Xen-devel] expandable grant table bug? > Hi All, > > Grant table had been expanded before. > As a result, it is thought that it came to be able to use four VNIF or more. > > The PV domain operated without trouble. > However, VNIF can be only used up to three in DomVTx(x86). > > # xm network-attach 27 > # xm network-attach 27 > # xm network-attach 27 > # xm network-attach 27 > # xm network-list 27 > Idx BE MAC Addr. handle state evt-ch tx-/rx-ring-ref BE-path > 0 0 02:17:42:2f:01:11 0 4 5 1280 /1281 > /local/domain/0/backend/vif/27/0 > 1 0 02:17:42:2f:03:11 1 4 6 1282 /1283 > /local/domain/0/backend/vif/27/1 > 2 0 00:16:3e:4d:2f:0e 2 4 7 1792 /1793 > /local/domain/0/backend/vif/27/2 > 3 0 00:16:3e:11:35:e0 3 6 -1 -1 /-1 > /local/domain/0/backend/vif/27/3 > > The test environment is as follows. > - xen-unstable.hg : cs15072 > - DomVTx(X86) with PV-ON-HVM > > This problem was investigated a little. > The cause is not to be able to execute HYPERVISOR_grant_table_op from the hvm > domain. > Therefore, the number of boot_max_nr_grant_frames is four. > > ・unmodified_drivers/linux-2.6/platform-pci/platform-pci.c >   platform_pci_init() > -> ・linux-2.6-xen-sparse/drivers/xen/core/gnttab.c >   gnttab_init() >   __max_nr_grant_frames() > > The size of the grant table is acquired here. > > 404 static unsigned int __max_nr_grant_frames(void) > 405 { > 406 struct gnttab_query_size query; > 407 int rc; > 408 > 409 query.dom = DOMID_SELF; > 410 > 411 rc = HYPERVISOR_grant_table_op(GNTTABOP_query_size, &query, 1); <<== > This > 412 if ((rc < 0) || (query.status != GNTST_okay)) > 413 return 4; /* Legacy max supported number of frames */ > 414 > 415 return query.max_nr_frames; > 416 } > > => ・xen/arch/x86/hvm/hvm.c > 736 int hvm_do_hypercall(struct cpu_user_regs *regs) > 737 { > ... > 759 if ( (eax >= NR_hypercalls) || !hvm_hypercall32_table[eax] ) > 760 { > 761 if ( eax != __HYPERVISOR_grant_table_op ) > 762 gdprintk(XENLOG_WARNING, "HVM vcpu %d:%d bad hypercall > %u.\n", > 763 current->domain->domain_id, current->vcpu_id, eax); > 764 regs->eax = -ENOSYS; > 765 return HVM_HCALL_completed; > 766 } > > hvm_hypercall32_table is as follows. > Therefore, grant_table_op cannot be called. > > 726 static hvm_hypercall_t *hvm_hypercall32_table[NR_hypercalls] = { > 727 HYPERCALL_COMPAT32(memory_op), > 728 HYPERCALL(xen_version), > 729 HYPERCALL(event_channel_op), > 730 HYPERCALL(sched_op), > 731 HYPERCALL(hvm_op) > 732 }; > > Cannot grant_table_op make it call from the hvm domain? > > How should we correct it if so? > > Best Regard, > > -- > Takanori Kasai ------=_NextPart_000_0C9E_01C7A302.DCFC1AC0 Content-Type: application/octet-stream; name="fix-expandable-gnttab-x86.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="fix-expandable-gnttab-x86.patch" # HG changeset patch=0A= # User kasai.takanori@jp.fujitsu.com=0A= # Date 1180524578 -32400=0A= # Node ID c1681085bf42c8fa639774ac91f3ca8fd2b127a0=0A= # Parent 089696e0c60379e2bb9cfcc988d35aa1bdc261de=0A= Fix expandable grant table for x86.=0A= =0A= Signed-off-by: Takanori Kasai =0A= Signed-off-by: Tsunehisa Doi =0A= =0A= diff -r 089696e0c603 -r c1681085bf42 xen/arch/x86/hvm/hvm.c=0A= --- a/xen/arch/x86/hvm/hvm.c Thu May 17 11:42:46 2007 +0100=0A= +++ b/xen/arch/x86/hvm/hvm.c Wed May 30 20:29:38 2007 +0900=0A= @@ -667,6 +667,7 @@ static hvm_hypercall_t *hvm_hypercall32_=0A= HYPERCALL(memory_op),=0A= HYPERCALL(multicall),=0A= HYPERCALL(xen_version),=0A= + HYPERCALL(grant_table_op),=0A= HYPERCALL(event_channel_op),=0A= HYPERCALL(sched_op),=0A= HYPERCALL(hvm_op)=0A= @@ -718,6 +719,7 @@ static hvm_hypercall_t *hvm_hypercall64_=0A= static hvm_hypercall_t *hvm_hypercall64_table[NR_hypercalls] =3D {=0A= HYPERCALL(memory_op),=0A= HYPERCALL(xen_version),=0A= + HYPERCALL(grant_table_op),=0A= HYPERCALL(event_channel_op),=0A= HYPERCALL(sched_op),=0A= HYPERCALL(hvm_op)=0A= @@ -726,6 +728,7 @@ static hvm_hypercall_t *hvm_hypercall32_=0A= static hvm_hypercall_t *hvm_hypercall32_table[NR_hypercalls] =3D {=0A= HYPERCALL_COMPAT32(memory_op),=0A= HYPERCALL(xen_version),=0A= + HYPERCALL(grant_table_op),=0A= HYPERCALL(event_channel_op),=0A= HYPERCALL(sched_op),=0A= HYPERCALL(hvm_op)=0A= @@ -758,9 +761,6 @@ int hvm_do_hypercall(struct cpu_user_reg=0A= =0A= if ( (eax >=3D NR_hypercalls) || !hvm_hypercall32_table[eax] )=0A= {=0A= - if ( eax !=3D __HYPERVISOR_grant_table_op )=0A= - gdprintk(XENLOG_WARNING, "HVM vcpu %d:%d bad hypercall = %u.\n",=0A= - current->domain->domain_id, current->vcpu_id, eax);=0A= regs->eax =3D -ENOSYS;=0A= return HVM_HCALL_completed;=0A= }=0A= @@ -770,7 +770,8 @@ int hvm_do_hypercall(struct cpu_user_reg=0A= * For now we also need to flush when pages are added, as qemu-dm = is not=0A= * yet capable of faulting pages into an existing valid mapcache = bucket.=0A= */=0A= - flush =3D (eax =3D=3D __HYPERVISOR_memory_op);=0A= + flush =3D ((eax =3D=3D __HYPERVISOR_memory_op) ||=0A= + (eax =3D=3D __HYPERVISOR_grant_table_op)); /* needed ? */=0A= this_cpu(hc_preempted) =3D 0;=0A= =0A= #ifdef __x86_64__=0A= diff -r 089696e0c603 -r c1681085bf42 xen/common/grant_table.c=0A= --- a/xen/common/grant_table.c Thu May 17 11:42:46 2007 +0100=0A= +++ b/xen/common/grant_table.c Wed May 30 20:29:38 2007 +0900=0A= @@ -1207,6 +1207,9 @@ do_grant_table_op(=0A= }=0A= case GNTTABOP_setup_table:=0A= {=0A= + rc =3D -ENOSYS;=0A= + if ( unlikely(is_hvm_domain(d)) )=0A= + goto out;=0A= rc =3D gnttab_setup_table(=0A= guest_handle_cast(uop, gnttab_setup_table_t), count);=0A= break;=0A= ------=_NextPart_000_0C9E_01C7A302.DCFC1AC0 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel ------=_NextPart_000_0C9E_01C7A302.DCFC1AC0--