Skip to contentSkip to conversation

domain builder: Fix sp_extents allocation

PATCH In review Samuel Thibault 2 participants 4 messages Jul 31, 2008

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 domain builder: Fix sp_extents allocation

domain builder: Fix sp_extents allocation

We do not need more than count elements in the sp_extents array.

tools/libxc/xc_hvm_build.c +1 -1
diff -r e355f9dce939 tools/libxc/xc_hvm_build.c
@@ -229,7 +229,7 @@ static int setup_guest(int xc_handle,
         if ( ((count | cur_pages) & (SUPERPAGE_NR_PFNS - 1)) == 0 )
         {
             long done;
-            xen_pfn_t sp_extents[2048 >> SUPERPAGE_PFN_SHIFT];
+            xen_pfn_t sp_extents[count >> SUPERPAGE_PFN_SHIFT];
             struct xen_memory_reservation sp_req = {
                 .nr_extents   = count >> SUPERPAGE_PFN_SHIFT,
                 .extent_order = SUPERPAGE_PFN_SHIFT,
#1 lore raw

Doesn't this turn the array allocation into a dynamic allocation? I feel a bit dubious about that.

-- Keir

Quoted 21 lines · Samuel Thibault

domain builder: Fix sp_extents allocation

We do not need more than count elements in the sp_extents array.

diff -r e355f9dce939 tools/libxc/xc_hvm_build.c

tools/libxc/xc_hvm_build.c Thu Jul 31 11:43:36 2008 +0100 renamed from tools/libxc/xc_hvm_build.c Wed Jul 30 17:20:25 2008 +0100 +1 -1
@@ -229,7 +229,7 @@ static int setup_guest(int xc_handle,
         if ( ((count | cur_pages) & (SUPERPAGE_NR_PFNS - 1)) == 0 )
         {
             long done;
-            xen_pfn_t sp_extents[2048 >> SUPERPAGE_PFN_SHIFT];
+            xen_pfn_t sp_extents[count >> SUPERPAGE_PFN_SHIFT];
             struct xen_memory_reservation sp_req = {
                 .nr_extents   = count >> SUPERPAGE_PFN_SHIFT,
                 .extent_order = SUPERPAGE_PFN_SHIFT,

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

#2 lore raw
Quoted 8 lines · Keir Fraser, le Thu 31 Jul 2008 12:19:18 +0100, a écrit :

Doesn't this turn the array allocation into a dynamic allocation? I feel a bit dubious about that.

Quoted 5 lines
         {
             long done;
tools/libxc/xc_hvm_build.c +1 -1
-            xen_pfn_t sp_extents[2048 >> SUPERPAGE_PFN_SHIFT];
+            xen_pfn_t sp_extents[count >> SUPERPAGE_PFN_SHIFT];
             struct xen_memory_reservation sp_req = {

Err, I'd think that it just turns a

sub (2048>>SUPERPAGE_PFN_SHIFT) * sizeof(xen_pfn_t), %esp

into a

mov count, %eax
shr SUPERPAGE_PFN_SHIFT - log2(sizeof(xen_pfn_t)), %eax sub %eax, %esp

Samuel

#3 lore raw
Quoted 12 lines · Samuel Thibault
Quoted 8 lines · Keir Fraser, le Thu 31 Jul 2008 12:19:18 +0100, a écrit :

Doesn't this turn the array allocation into a dynamic allocation? I feel a bit dubious about that.

Quoted 5 lines
         {
             long done;
tools/libxc/xc_hvm_build.c +1 -1
-            xen_pfn_t sp_extents[2048 >> SUPERPAGE_PFN_SHIFT];
+            xen_pfn_t sp_extents[count >> SUPERPAGE_PFN_SHIFT];
             struct xen_memory_reservation sp_req = {

Err, I'd think that it just turns a

Quoted 7 lines

sub (2048>>SUPERPAGE_PFN_SHIFT) * sizeof(xen_pfn_t), %esp

into a

mov count, %eax
shr SUPERPAGE_PFN_SHIFT - log2(sizeof(xen_pfn_t)), %eax sub %eax, %esp

Yes, good point!

-- Keir