Skip to contentSkip to conversation

Fix expandable grant table for x86

PATCH New Kasai Takanori 1 participant 1 message May 30, 2007

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Fix expandable grant table for x86

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.

Best Regards,

--
Takanori Kasai

----- Original Message ----- From: "Kasai Takanori" <[email protected]>
To: "xen-devel" <[email protected]>
Sent: Thursday, May 24, 2007 8:50 PM
Subject: [Xen-devel] expandable grant table bug?

Quoted 79 lines

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 };

Quoted 8 lines

Cannot grant_table_op make it call from the hvm domain?

How should we correct it if so?

Best Regard,

--
Takanori Kasai

# HG changeset patch
# User [email protected]
# Date 1180524578 -32400
# Node ID c1681085bf42c8fa639774ac91f3ca8fd2b127a0 # Parent 089696e0c60379e2bb9cfcc988d35aa1bdc261de Fix expandable grant table for x86.

xen/arch/x86/hvm/hvm.c +5 -4
diff -r 089696e0c603 -r c1681085bf42 xen/arch/x86/hvm/hvm.c
@@ -667,6 +667,7 @@ static hvm_hypercall_t *hvm_hypercall32_
     HYPERCALL(memory_op),
     HYPERCALL(multicall),
     HYPERCALL(xen_version),
+    HYPERCALL(grant_table_op),
     HYPERCALL(event_channel_op),
     HYPERCALL(sched_op),
     HYPERCALL(hvm_op)
@@ -718,6 +719,7 @@ static hvm_hypercall_t *hvm_hypercall64_
 static hvm_hypercall_t *hvm_hypercall64_table[NR_hypercalls] = {
     HYPERCALL(memory_op),
     HYPERCALL(xen_version),
+    HYPERCALL(grant_table_op),
     HYPERCALL(event_channel_op),
     HYPERCALL(sched_op),
     HYPERCALL(hvm_op)
@@ -726,6 +728,7 @@ static hvm_hypercall_t *hvm_hypercall32_
 static hvm_hypercall_t *hvm_hypercall32_table[NR_hypercalls] = {
     HYPERCALL_COMPAT32(memory_op),
     HYPERCALL(xen_version),
+    HYPERCALL(grant_table_op),
     HYPERCALL(event_channel_op),
     HYPERCALL(sched_op),
     HYPERCALL(hvm_op)
@@ -758,9 +761,6 @@ int hvm_do_hypercall(struct cpu_user_reg
 
     if ( (eax >= NR_hypercalls) || !hvm_hypercall32_table[eax] )
     {
-        if ( eax != __HYPERVISOR_grant_table_op )
-            gdprintk(XENLOG_WARNING, "HVM vcpu %d:%d bad hypercall %u.\n",
-                     current->domain->domain_id, current->vcpu_id, eax);
         regs->eax = -ENOSYS;
         return HVM_HCALL_completed;
     }
@@ -770,7 +770,8 @@ int hvm_do_hypercall(struct cpu_user_reg
      * For now we also need to flush when pages are added, as qemu-dm is not
      * yet capable of faulting pages into an existing valid mapcache bucket.
      */
-    flush = (eax == __HYPERVISOR_memory_op);
+    flush = ((eax == __HYPERVISOR_memory_op) ||
+             (eax == __HYPERVISOR_grant_table_op)); /* needed ? */
     this_cpu(hc_preempted) = 0;
 
 #ifdef __x86_64__
xen/common/grant_table.c +3 -0
diff -r 089696e0c603 -r c1681085bf42 xen/common/grant_table.c
@@ -1207,6 +1207,9 @@ do_grant_table_op(
     }
     case GNTTABOP_setup_table:
     {
+        rc = -ENOSYS;
+        if ( unlikely(is_hvm_domain(d)) )
+            goto out;
         rc = gnttab_setup_table(
             guest_handle_cast(uop, gnttab_setup_table_t), count);
         break;

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel