ia64/xen-unstable

changeset 11135:5de3bc3c6297

merge
author ack@localhost.localdomain
date Tue Aug 15 11:16:46 2006 +0100 (2006-08-15)
parents d48842f924d0 438ed1c4b391
children 01a4266e4dc9
files
line diff
     1.1 --- a/.hgignore	Tue Aug 15 11:13:04 2006 +0100
     1.2 +++ b/.hgignore	Tue Aug 15 11:16:46 2006 +0100
     1.3 @@ -199,5 +199,6 @@
     1.4  ^xen/xen\..*$
     1.5  ^xen/arch/powerpc/dom0\.bin$
     1.6  ^xen/arch/powerpc/asm-offsets\.s$
     1.7 -^xen/arch/powerpc/firmware
     1.8 -^xen/arch/powerpc/firmware_image
     1.9 +^xen/arch/powerpc/firmware$
    1.10 +^xen/arch/powerpc/firmware_image$
    1.11 +^xen/arch/powerpc/xen\.lds$
     2.1 --- a/tools/firmware/vmxassist/head.S	Tue Aug 15 11:13:04 2006 +0100
     2.2 +++ b/tools/firmware/vmxassist/head.S	Tue Aug 15 11:16:46 2006 +0100
     2.3 @@ -114,8 +114,6 @@ 1:
     2.4  #ifdef TEST
     2.5  	xorl	%edx, %edx
     2.6  #endif
     2.7 -	movl	%edx, booting_cpu
     2.8 -	movl	%ebx, booting_vector
     2.9  
    2.10  	/* clear bss */
    2.11  	cld
    2.12 @@ -125,6 +123,9 @@ 1:
    2.13  	subl	%edi, %ecx
    2.14  	rep	stosb
    2.15  
    2.16 +	movl	%edx, booting_cpu
    2.17 +	movl	%ebx, booting_vector
    2.18 +
    2.19  	/* make sure we are in a sane world */
    2.20  	clts
    2.21  
     3.1 --- a/tools/firmware/vmxassist/vm86.c	Tue Aug 15 11:13:04 2006 +0100
     3.2 +++ b/tools/firmware/vmxassist/vm86.c	Tue Aug 15 11:16:46 2006 +0100
     3.3 @@ -983,7 +983,9 @@ set_mode(struct regs *regs, enum vm86_mo
     3.4  	case VM86_PROTECTED:
     3.5  		if (mode == VM86_REAL_TO_PROTECTED) {
     3.6  			protected_mode(regs);
     3.7 -			break;
     3.8 +//			printf("<VM86_PROTECTED>\n");
     3.9 +			mode = newmode;
    3.10 +			return;
    3.11  		} else
    3.12  			panic("unexpected protected mode transition");
    3.13  		break;
    3.14 @@ -1170,6 +1172,26 @@ inbyte(struct regs *regs, unsigned prefi
    3.15  	return 1;
    3.16  }
    3.17  
    3.18 +static void
    3.19 +pushrm(struct regs *regs, int prefix, unsigned modrm)
    3.20 +{
    3.21 +	unsigned n = regs->eip;
    3.22 +	unsigned addr;
    3.23 +	unsigned data;
    3.24 +
    3.25 +	addr  = operand(prefix, regs, modrm);
    3.26 +	
    3.27 +	if (prefix & DATA32) {
    3.28 +		data = read32(addr);
    3.29 +		push32(regs, data);
    3.30 +	} else {
    3.31 +		data = read16(addr);
    3.32 +		push16(regs, data);
    3.33 +	}
    3.34 +
    3.35 +	TRACE((regs, (regs->eip - n) + 1, "push *0x%x", addr));
    3.36 +}
    3.37 +
    3.38  enum { OPC_INVALID, OPC_EMULATED };
    3.39  
    3.40  /*
    3.41 @@ -1186,6 +1208,14 @@ opcode(struct regs *regs)
    3.42  
    3.43  	for (;;) {
    3.44  		switch ((opc = fetch8(regs))) {
    3.45 +		case 0x07:
    3.46 +			if (prefix & DATA32)
    3.47 +				regs->ves = pop32(regs);
    3.48 +			else
    3.49 +				regs->ves = pop16(regs);
    3.50 +			TRACE((regs, regs->eip - eip, "pop %%es"));
    3.51 +			return OPC_EMULATED;
    3.52 +
    3.53  		case 0x0F: /* two byte opcode */
    3.54  			if (mode == VM86_PROTECTED)
    3.55  				goto invalid;
    3.56 @@ -1288,6 +1318,22 @@ opcode(struct regs *regs)
    3.57                          return OPC_EMULATED;
    3.58  
    3.59  		case 0x89: /* addr32 mov r16, r/m16 */
    3.60 +			if (mode == VM86_PROTECTED_TO_REAL) {
    3.61 +				unsigned modrm = fetch8(regs);
    3.62 +				unsigned addr = operand(prefix, regs, modrm);
    3.63 +				unsigned val, r = (modrm >> 3) & 7;
    3.64 +				
    3.65 +				if (prefix & DATA32) {
    3.66 +					val = getreg16(regs, r);
    3.67 +					write32(addr, val);
    3.68 +				} else {
    3.69 +					val = getreg32(regs, r);
    3.70 +					write16(addr, MASK16(val));
    3.71 +				}
    3.72 +				TRACE((regs, regs->eip - eip,
    3.73 +					"mov %%%s, *0x%x", rnames[r], addr));
    3.74 +				return OPC_EMULATED;
    3.75 +			}
    3.76  		case 0x8B: /* addr32 mov r/m16, r16 */
    3.77  			if (mode != VM86_REAL && mode != VM86_REAL_TO_PROTECTED)
    3.78  				goto invalid;
    3.79 @@ -1326,6 +1372,37 @@ opcode(struct regs *regs)
    3.80  			regs->eflags |= EFLAGS_VM;
    3.81  			return OPC_EMULATED;
    3.82  
    3.83 +		case 0xA1: /* mov ax, r/m16 */ 
    3.84 +			{
    3.85 +				int addr, data;
    3.86 +				int seg = segment(prefix, regs, regs->vds);
    3.87 +				if (prefix & DATA32) {
    3.88 +					addr = address(regs, seg, fetch32(regs));
    3.89 +					data = read32(addr);
    3.90 +					setreg32(regs, 0, data);
    3.91 +				} else {
    3.92 +					addr = address(regs, seg, fetch16(regs));
    3.93 +					data = read16(addr);
    3.94 +					setreg16(regs, 0, data);
    3.95 +				}
    3.96 +				TRACE((regs, regs->eip - eip, "mov *0x%x, %%ax", addr));
    3.97 +			}
    3.98 +			return OPC_EMULATED;
    3.99 +
   3.100 +		case 0xBB: /* mov bx, imm16 */
   3.101 +			{
   3.102 +				int data;
   3.103 +				if (prefix & DATA32) {
   3.104 +					data = fetch32(regs);
   3.105 +					setreg32(regs, 3, data);
   3.106 +				} else {
   3.107 +					data = fetch16(regs);
   3.108 +					setreg16(regs, 3, data);
   3.109 +				}
   3.110 +				TRACE((regs, regs->eip - eip, "mov $0x%x, %%bx", data));
   3.111 +			}
   3.112 +			return OPC_EMULATED;
   3.113 +
   3.114  		case 0xC6: /* addr32 movb $imm, r/m8 */
   3.115                          if ((prefix & ADDR32) == 0)
   3.116                                  goto invalid;
   3.117 @@ -1380,21 +1457,25 @@ opcode(struct regs *regs)
   3.118  			goto invalid;
   3.119  
   3.120  		case 0xFF: /* jmpl (indirect) */
   3.121 -			if ((mode == VM86_REAL_TO_PROTECTED) ||
   3.122 -			    (mode == VM86_PROTECTED_TO_REAL)) {
   3.123 -			 	unsigned modrm = fetch8(regs);
   3.124 -				
   3.125 +			{
   3.126 +				unsigned modrm = fetch8(regs);
   3.127  				switch((modrm >> 3) & 7) {
   3.128 -				case 5:
   3.129 -				  jmpl_indirect(regs, prefix, modrm);
   3.130 -				  return OPC_INVALID;
   3.131 +				case 5: /* jmpl (indirect) */
   3.132 +					if ((mode == VM86_REAL_TO_PROTECTED) ||
   3.133 +					    (mode == VM86_PROTECTED_TO_REAL)) {
   3.134 +						jmpl_indirect(regs, prefix, modrm);
   3.135 +						return OPC_INVALID;
   3.136 +					}
   3.137 +					goto invalid;
   3.138 +
   3.139 +				case 6: /* push r/m16 */
   3.140 +					pushrm(regs, prefix, modrm);
   3.141 +					return OPC_EMULATED;
   3.142  
   3.143  				default:
   3.144 -				  break;
   3.145 +					goto invalid;
   3.146  				}
   3.147 -
   3.148  			}
   3.149 -			goto invalid;
   3.150  
   3.151  		case 0xEB: /* short jump */
   3.152  			if ((mode == VM86_REAL_TO_PROTECTED) ||
     4.1 --- a/tools/python/xen/xend/XendDomainInfo.py	Tue Aug 15 11:13:04 2006 +0100
     4.2 +++ b/tools/python/xen/xend/XendDomainInfo.py	Tue Aug 15 11:16:46 2006 +0100
     4.3 @@ -1272,12 +1272,9 @@ class XendDomainInfo:
     4.4              # repin domain vcpus if a restricted cpus list is provided
     4.5              # this is done prior to memory allocation to aide in memory
     4.6              # distribution for NUMA systems.
     4.7 -            cpus = self.info['cpus']
     4.8 -            if cpus is not None and len(cpus) > 0:
     4.9 +            if self.info['cpus'] is not None and len(self.info['cpus']) > 0:
    4.10                  for v in range(0, self.info['max_vcpu_id']+1):
    4.11 -                    # pincpu takes a list of ints
    4.12 -                    cpu = [ int( cpus[v % len(cpus)] ) ]
    4.13 -                    xc.vcpu_setaffinity(self.domid, v, cpu)
    4.14 +                    xc.vcpu_setaffinity(self.domid, v, self.info['cpus'])
    4.15  
    4.16              # set domain maxmem in KiB
    4.17              xc.domain_setmaxmem(self.domid, self.info['maxmem'] * 1024)
     5.1 --- a/tools/xenmon/xenbaked.c	Tue Aug 15 11:13:04 2006 +0100
     5.2 +++ b/tools/xenmon/xenbaked.c	Tue Aug 15 11:16:46 2006 +0100
     5.3 @@ -444,14 +444,11 @@ struct t_rec **init_rec_ptrs(struct t_bu
     5.4   */
     5.5  unsigned int get_num_cpus(void)
     5.6  {
     5.7 -    dom0_op_t op;
     5.8 +    xc_physinfo_t physinfo;
     5.9      int xc_handle = xc_interface_open();
    5.10      int ret;
    5.11  
    5.12 -    op.cmd = DOM0_PHYSINFO;
    5.13 -    op.interface_version = DOM0_INTERFACE_VERSION;
    5.14 -
    5.15 -    ret = xc_dom0_op(xc_handle, &op);
    5.16 +    ret = xc_physinfo(xc_handle, &physinfo);
    5.17  
    5.18      if ( ret != 0 )
    5.19      {
    5.20 @@ -460,12 +457,12 @@ unsigned int get_num_cpus(void)
    5.21      }
    5.22  
    5.23      xc_interface_close(xc_handle);
    5.24 -    opts.cpu_freq = (double)op.u.physinfo.cpu_khz/1000.0;
    5.25 +    opts.cpu_freq = (double)physinfo.cpu_khz/1000.0;
    5.26  
    5.27 -    return (op.u.physinfo.threads_per_core *
    5.28 -            op.u.physinfo.cores_per_socket *
    5.29 -            op.u.physinfo.sockets_per_node *
    5.30 -            op.u.physinfo.nr_nodes);
    5.31 +    return (physinfo.threads_per_core *
    5.32 +            physinfo.cores_per_socket *
    5.33 +            physinfo.sockets_per_node *
    5.34 +            physinfo.nr_nodes);
    5.35  }
    5.36  
    5.37  
     6.1 --- a/xen/arch/powerpc/Makefile	Tue Aug 15 11:13:04 2006 +0100
     6.2 +++ b/xen/arch/powerpc/Makefile	Tue Aug 15 11:16:46 2006 +0100
     6.3 @@ -49,7 +49,7 @@ obj-y += elf32.o
     6.4  PPC_C_WARNINGS += -Wundef -Wmissing-prototypes -Wmissing-declarations
     6.5  CFLAGS += $(PPC_C_WARNINGS)
     6.6  
     6.7 -LINK=0x3000000
     6.8 +LINK=0x400000
     6.9  boot32_link_base = $(LINK)
    6.10  xen_link_offset  = 100
    6.11  xen_link_base    = $(patsubst %000,%$(xen_link_offset),$(LINK))
    6.12 @@ -83,8 +83,10 @@ physdev.o: ../x86/physdev.c
    6.13  
    6.14  HDRS += $(wildcard *.h)
    6.15  
    6.16 -CMDLINE = "xen"
    6.17 -boot_of.o: CFLAGS += -DCMDLINE="\"$(CMDLINE)\""
    6.18 +# The first token in the arguments will be silently dropped.
    6.19 +IMAGENAME = xen
    6.20 +CMDLINE = ""
    6.21 +boot_of.o: CFLAGS += -DCMDLINE="\"$(IMAGENAME) $(CMDLINE)\""
    6.22  
    6.23  start.o: boot/start.S
    6.24  	$(CC) $(CFLAGS) -D__ASSEMBLY__ -c $< -o $@
     7.1 --- a/xen/arch/powerpc/boot_of.c	Tue Aug 15 11:13:04 2006 +0100
     7.2 +++ b/xen/arch/powerpc/boot_of.c	Tue Aug 15 11:16:46 2006 +0100
     7.3 @@ -13,7 +13,7 @@
     7.4   * along with this program; if not, write to the Free Software
     7.5   * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
     7.6   *
     7.7 - * Copyright (C) IBM Corp. 2005
     7.8 + * Copyright (C) IBM Corp. 2005, 2006
     7.9   *
    7.10   * Authors: Jimi Xenidis <jimix@watson.ibm.com>
    7.11   */
    7.12 @@ -304,12 +304,11 @@ static int __init of_instance_to_path(in
    7.13  
    7.14  static int __init of_start_cpu(int cpu, u32 pc, u32 reg)
    7.15  {
    7.16 -    int rets[1] = { OF_FAILURE };
    7.17 +    int ret;
    7.18  
    7.19 -    if ( of_call("start-cpu", 3, 0, rets, cpu, pc, reg) == OF_FAILURE )
    7.20 -        return OF_FAILURE;
    7.21 +    ret = of_call("start-cpu", 3, 0, NULL, cpu, pc, reg);
    7.22  
    7.23 -    return rets[0];
    7.24 +    return ret;
    7.25  }
    7.26  
    7.27  static void __init of_test(const char *of_method_name)
    7.28 @@ -760,19 +759,30 @@ static int __init boot_of_serial(void *o
    7.29      if (n == OF_FAILURE) {
    7.30          of_panic("instance-to-package of /chosen/stdout: failed\n");
    7.31      }
    7.32 +    
    7.33 +    /* Prune all serial devices from the device tree, including the
    7.34 +     * one pointed to by /chosen/stdout, because a guest domain can
    7.35 +     * initialize them and in so doing corrupt our console output.
    7.36 +     */
    7.37 +    for (p = n; p > 0; p = of_getpeer(p)) {
    7.38 +        char type[32];
    7.39  
    7.40 -    /* prune this from the oftree */
    7.41 -    rc = of_package_to_path(n, buf, sizeof(buf));
    7.42 -    if (rc == OF_FAILURE) {
    7.43 -        of_panic("package-to-path of /chosen/stdout: failed\n");
    7.44 +        rc = of_package_to_path(p, buf, sizeof(buf));
    7.45 +        if (rc == OF_FAILURE)
    7.46 +            of_panic("package-to-path failed\n");
    7.47 +
    7.48 +        rc = of_getprop(p, "device_type", type, sizeof (type));
    7.49 +        if (rc == OF_FAILURE)
    7.50 +            of_panic("fetching device type failed\n");
    7.51 +
    7.52 +        if (strcmp(type, "serial") != 0)
    7.53 +            continue;
    7.54 +
    7.55 +        of_printf("pruning `%s' from devtree\n", buf);
    7.56 +        rc = ofd_prune_path(oftree, buf);
    7.57 +        if (rc < 0)
    7.58 +            of_panic("prune of `%s' failed\n", buf);
    7.59      }
    7.60 -    of_printf("Pruning from devtree: %s\n"
    7.61 -              "  since Xen will be using it for console\n", buf);
    7.62 -    rc = ofd_prune_path(oftree, buf);
    7.63 -    if (rc < 0) {
    7.64 -        of_panic("prune path \"%s\" failed\n", buf);
    7.65 -    }
    7.66 -    
    7.67  
    7.68      p = of_getparent(n);
    7.69      if (p == OF_FAILURE) {
    7.70 @@ -799,7 +809,6 @@ static int __init boot_of_serial(void *o
    7.71      if (rc == OF_FAILURE) {
    7.72          of_panic("%s: no location for serial port\n", __func__);
    7.73      }
    7.74 -    ns16550.io_base = val[1];
    7.75  
    7.76      ns16550.baud = BAUD_AUTO;
    7.77      ns16550.data_bits = 8;
     8.1 --- a/xen/arch/powerpc/domain.c	Tue Aug 15 11:13:04 2006 +0100
     8.2 +++ b/xen/arch/powerpc/domain.c	Tue Aug 15 11:16:46 2006 +0100
     8.3 @@ -73,10 +73,9 @@ unsigned long hypercall_create_continuat
     8.4  
     8.5  int arch_domain_create(struct domain *d)
     8.6  {
     8.7 -    struct page_info *rma;
     8.8      unsigned long rma_base;
     8.9 -    unsigned long rma_size;
    8.10 -    unsigned int rma_order;
    8.11 +    unsigned long rma_sz;
    8.12 +    uint htab_order;
    8.13  
    8.14      if (d->domain_id == IDLE_DOMAIN_ID) {
    8.15          d->shared_info = (void *)alloc_xenheap_page();
    8.16 @@ -85,25 +84,21 @@ int arch_domain_create(struct domain *d)
    8.17          return 0;
    8.18      }
    8.19  
    8.20 -    rma_order = cpu_rma_order();
    8.21 -    rma_size = 1UL << rma_order << PAGE_SHIFT;
    8.22 +    d->arch.rma_order = cpu_rma_order();
    8.23 +    rma_sz = rma_size(d->arch.rma_order);
    8.24  
    8.25      /* allocate the real mode area */
    8.26 -    d->max_pages = 1UL << rma_order;
    8.27 -    rma = alloc_domheap_pages(d, rma_order, 0);
    8.28 -    if (NULL == rma)
    8.29 +    d->max_pages = 1UL << d->arch.rma_order;
    8.30 +    d->tot_pages = 0;
    8.31 +    d->arch.rma_page = alloc_domheap_pages(d, d->arch.rma_order, 0);
    8.32 +    if (NULL == d->arch.rma_page)
    8.33          return 1;
    8.34 -    rma_base = page_to_maddr(rma);
    8.35 -
    8.36 -    BUG_ON(rma_base & (rma_size-1)); /* check alignment */
    8.37 +    rma_base = page_to_maddr(d->arch.rma_page);
    8.38  
    8.39 -    d->arch.rma_base = rma_base;
    8.40 -    d->arch.rma_size = rma_size;
    8.41 +    BUG_ON(rma_base & (rma_sz - 1)); /* check alignment */
    8.42  
    8.43 -    printk("clearing RMO: 0x%lx[0x%lx]\n", rma_base, rma_size);
    8.44 -    memset((void *)rma_base, 0, rma_size);
    8.45 -
    8.46 -    htab_alloc(d, LOG_DEFAULT_HTAB_BYTES);
    8.47 +    printk("clearing RMO: 0x%lx[0x%lx]\n", rma_base, rma_sz);
    8.48 +    memset((void *)rma_base, 0, rma_sz);
    8.49  
    8.50      d->shared_info = (shared_info_t *)
    8.51          (rma_addr(&d->arch, RMA_SHARED_INFO) + rma_base);
    8.52 @@ -111,12 +106,22 @@ int arch_domain_create(struct domain *d)
    8.53      d->arch.large_page_sizes = 1;
    8.54      d->arch.large_page_shift[0] = 24; /* 16 M for 970s */
    8.55  
    8.56 +    /* FIXME: we need to the the maximum addressible memory for this
    8.57 +     * domain to calculate this correctly. It should probably be set
    8.58 +     * by the managment tools */
    8.59 +    htab_order = d->arch.rma_order - 6; /* (1/64) */
    8.60 +    if (test_bit(_DOMF_privileged, &d->domain_flags)) {
    8.61 +        /* bump the htab size of privleged domains */
    8.62 +        ++htab_order;
    8.63 +    }
    8.64 +    htab_alloc(d, htab_order);
    8.65 +
    8.66      return 0;
    8.67  }
    8.68  
    8.69  void arch_domain_destroy(struct domain *d)
    8.70  {
    8.71 -    unimplemented();
    8.72 +    htab_free(d);
    8.73  }
    8.74  
    8.75  void machine_halt(void)
    8.76 @@ -258,7 +263,7 @@ void sync_vcpu_execstate(struct vcpu *v)
    8.77  
    8.78  void domain_relinquish_resources(struct domain *d)
    8.79  {
    8.80 -    /* nothing to do? */
    8.81 +    free_domheap_pages(d->arch.rma_page, d->arch.rma_order);
    8.82  }
    8.83  
    8.84  void arch_dump_domain_info(struct domain *d)
     9.1 --- a/xen/arch/powerpc/domain_build.c	Tue Aug 15 11:13:04 2006 +0100
     9.2 +++ b/xen/arch/powerpc/domain_build.c	Tue Aug 15 11:16:46 2006 +0100
     9.3 @@ -105,8 +105,8 @@ int construct_dom0(struct domain *d,
     9.4      struct domain_setup_info dsi;
     9.5      ulong dst;
     9.6      u64 *ofh_tree;
     9.7 -    ulong rma_sz = d->arch.rma_size;
     9.8 -    ulong rma = d->arch.rma_base;
     9.9 +    ulong rma_sz = rma_size(d->arch.rma_order);
    9.10 +    ulong rma = page_to_maddr(d->arch.rma_page);
    9.11      start_info_t *si;
    9.12      ulong eomem;
    9.13      int am64 = 1;
    9.14 @@ -145,7 +145,7 @@ int construct_dom0(struct domain *d,
    9.15  
    9.16      /* By default DOM0 is allocated all available memory. */
    9.17      d->max_pages = ~0U;
    9.18 -    d->tot_pages = (d->arch.rma_size >> PAGE_SHIFT);
    9.19 +    d->tot_pages = 1UL << d->arch.rma_order;
    9.20  
    9.21      ASSERT( image_len < rma_sz );
    9.22  
    10.1 --- a/xen/arch/powerpc/htab.c	Tue Aug 15 11:13:04 2006 +0100
    10.2 +++ b/xen/arch/powerpc/htab.c	Tue Aug 15 11:16:46 2006 +0100
    10.3 @@ -34,36 +34,35 @@ static ulong htab_calc_sdr1(ulong htab_a
    10.4      return (htab_addr | (sdr1_htabsize & SDR1_HTABSIZE_MASK));
    10.5  }
    10.6  
    10.7 -void htab_alloc(struct domain *d, int log_htab_bytes)
    10.8 +void htab_alloc(struct domain *d, uint order)
    10.9  {
   10.10      ulong htab_raddr;
   10.11 +    ulong log_htab_bytes = order + PAGE_SHIFT;
   10.12      ulong htab_bytes = 1UL << log_htab_bytes;
   10.13  
   10.14      /* XXX use alloc_domheap_pages instead? */
   10.15 -    htab_raddr = (ulong)alloc_xenheap_pages(log_htab_bytes - PAGE_SHIFT);
   10.16 +    htab_raddr = (ulong)alloc_xenheap_pages(order);
   10.17      ASSERT(htab_raddr != 0);
   10.18      /* XXX check alignment guarantees */
   10.19 -    ASSERT((htab_raddr & (htab_bytes-1)) == 0);
   10.20 +    ASSERT((htab_raddr & (htab_bytes - 1)) == 0);
   10.21  
   10.22      /* XXX slow. move memset out to service partition? */
   10.23      memset((void *)htab_raddr, 0, htab_bytes);
   10.24  
   10.25 +    d->arch.htab.order = order;
   10.26      d->arch.htab.log_num_ptes = log_htab_bytes - LOG_PTE_SIZE;
   10.27      d->arch.htab.sdr1 = htab_calc_sdr1(htab_raddr, log_htab_bytes);
   10.28      d->arch.htab.map = (union pte *)htab_raddr;
   10.29      d->arch.htab.shadow = xmalloc_array(ulong,
   10.30                                          1UL << d->arch.htab.log_num_ptes);
   10.31      ASSERT(d->arch.htab.shadow != NULL);
   10.32 -
   10.33 -    printf("%s: dom%x sdr1: %lx\n", __func__, d->domain_id, d->arch.htab.sdr1);
   10.34  }
   10.35  
   10.36  void htab_free(struct domain *d)
   10.37  {
   10.38      ulong htab_raddr = GET_HTAB(d);
   10.39  
   10.40 -    free_xenheap_pages((void *)htab_raddr,
   10.41 -                       (1UL << d->arch.htab.log_num_ptes) << LOG_PTE_SIZE);
   10.42 +    free_xenheap_pages((void *)htab_raddr, d->arch.htab.order);
   10.43      xfree(d->arch.htab.shadow);
   10.44  }
   10.45  
    11.1 --- a/xen/arch/powerpc/mm.c	Tue Aug 15 11:13:04 2006 +0100
    11.2 +++ b/xen/arch/powerpc/mm.c	Tue Aug 15 11:16:46 2006 +0100
    11.3 @@ -20,6 +20,7 @@
    11.4  
    11.5  #include <xen/config.h>
    11.6  #include <xen/mm.h>
    11.7 +#include <xen/shadow.h>
    11.8  #include <xen/kernel.h>
    11.9  #include <xen/sched.h>
   11.10  #include <asm/misc.h>
   11.11 @@ -108,8 +109,8 @@ extern void copy_page(void *dp, void *sp
   11.12  
   11.13  ulong pfn2mfn(struct domain *d, long pfn, int *type)
   11.14  {
   11.15 -    ulong rma_base_mfn = d->arch.rma_base >> PAGE_SHIFT;
   11.16 -    ulong rma_size_mfn = d->arch.rma_size >> PAGE_SHIFT;
   11.17 +    ulong rma_base_mfn = page_to_mfn(d->arch.rma_page);
   11.18 +    ulong rma_size_mfn = 1UL << d->arch.rma_order;
   11.19      ulong mfn;
   11.20      int t;
   11.21  
   11.22 @@ -139,3 +140,18 @@ ulong pfn2mfn(struct domain *d, long pfn
   11.23  
   11.24      return mfn;
   11.25  }
   11.26 +
   11.27 +void guest_physmap_add_page(
   11.28 +    struct domain *d, unsigned long gpfn, unsigned long mfn)
   11.29 +{
   11.30 +    panic("%s\n", __func__);
   11.31 +}
   11.32 +void guest_physmap_remove_page(
   11.33 +    struct domain *d, unsigned long gpfn, unsigned long mfn)
   11.34 +{
   11.35 +    panic("%s\n", __func__);
   11.36 +}
   11.37 +void shadow_drop_references(
   11.38 +    struct domain *d, struct page_info *page)
   11.39 +{
   11.40 +}
    12.1 --- a/xen/arch/powerpc/ofd_fixup.c	Tue Aug 15 11:13:04 2006 +0100
    12.2 +++ b/xen/arch/powerpc/ofd_fixup.c	Tue Aug 15 11:16:46 2006 +0100
    12.3 @@ -359,8 +359,8 @@ static ofdn_t ofd_memory_props(void *m, 
    12.4      ofdn_t n = -1;
    12.5      ulong start = 0;
    12.6      static char name[] = "memory";
    12.7 -    ulong mem_size = d->arch.rma_size;
    12.8 -    ulong chunk_size = d->arch.rma_size;
    12.9 +    ulong mem_size = rma_size(d->arch.rma_order);
   12.10 +    ulong chunk_size = rma_size(d->arch.rma_order);
   12.11  
   12.12      /* Remove all old memory props */
   12.13      do {
   12.14 @@ -424,12 +424,12 @@ static ofdn_t ofd_xen_props(void *m, str
   12.15          ASSERT(xl < sizeof (xen));
   12.16          ofd_prop_add(m, n, "version", xen, xl + 1);
   12.17  
   12.18 -        val[0] = (ulong)si - d->arch.rma_base;
   12.19 +        val[0] = (ulong)si - page_to_maddr(d->arch.rma_page);
   12.20          val[1] = PAGE_SIZE;
   12.21          ofd_prop_add(m, n, "start-info", val, sizeof (val));
   12.22  
   12.23          val[1] =  RMA_LAST_DOM0 * PAGE_SIZE;
   12.24 -        val[0] =  d->arch.rma_size - val[1];
   12.25 +        val[0] =  rma_size(d->arch.rma_order) - val[1];
   12.26          ofd_prop_add(m, n, "reserved", val, sizeof (val));
   12.27  
   12.28          n = ofd_node_add(m, n, console, sizeof (console));
    13.1 --- a/xen/arch/powerpc/papr/xlate.c	Tue Aug 15 11:13:04 2006 +0100
    13.2 +++ b/xen/arch/powerpc/papr/xlate.c	Tue Aug 15 11:16:46 2006 +0100
    13.3 @@ -258,8 +258,10 @@ static void h_enter(struct cpu_user_regs
    13.4          }
    13.5      }
    13.6  
    13.7 +#ifdef DEBUG
    13.8      /* If the PTEG is full then no additional values are returned. */
    13.9      printk("%s: PTEG FULL\n", __func__);
   13.10 +#endif
   13.11  
   13.12      regs->gprs[3] = H_PTEG_Full;
   13.13  }
    14.1 --- a/xen/arch/powerpc/powerpc64/ppc970.c	Tue Aug 15 11:13:04 2006 +0100
    14.2 +++ b/xen/arch/powerpc/powerpc64/ppc970.c	Tue Aug 15 11:16:46 2006 +0100
    14.3 @@ -34,7 +34,8 @@
    14.4  unsigned int cpu_rma_order(void)
    14.5  {
    14.6      /* XXX what about non-HV mode? */
    14.7 -    return 14; /* 1<<14<<PAGE_SIZE = 64M */
    14.8 +    uint rma_log_size = 6 + 20; /* 64M */
    14.9 +    return rma_log_size - PAGE_SHIFT;
   14.10  }
   14.11  
   14.12  void cpu_initialize(void)
   14.13 @@ -114,8 +115,8 @@ void cpu_init_vcpu(struct vcpu *v)
   14.14  {
   14.15      struct domain *d = v->domain;
   14.16      union hid4 hid4;
   14.17 -    ulong rma_base = d->arch.rma_base;
   14.18 -    ulong rma_size = d->arch.rma_size;
   14.19 +    ulong rma_base = page_to_maddr(d->arch.rma_page);
   14.20 +    ulong rma_size = rma_size(d->arch.rma_order);
   14.21  
   14.22      hid4.word = mfhid4();
   14.23  
    15.1 --- a/xen/arch/powerpc/setup.c	Tue Aug 15 11:13:04 2006 +0100
    15.2 +++ b/xen/arch/powerpc/setup.c	Tue Aug 15 11:16:46 2006 +0100
    15.3 @@ -214,7 +214,11 @@ static void __init __start_xen(multiboot
    15.4      if ((mbi->flags & MBI_CMDLINE) && (mbi->cmdline != 0))
    15.5          cmdline_parse(__va((ulong)mbi->cmdline));
    15.6  
    15.7 +    /* We initialise the serial devices very early so we can get debugging. */
    15.8 +    ns16550.io_base = 0x3f8;
    15.9      ns16550_init(0, &ns16550);
   15.10 +    ns16550.io_base = 0x2f8;
   15.11 +    ns16550_init(1, &ns16550);
   15.12      serial_init_preirq();
   15.13  
   15.14      init_console();
   15.15 @@ -273,12 +277,26 @@ static void __init __start_xen(multiboot
   15.16  
   15.17      printk("System RAM: %luMB (%lukB)\n", eomem >> 20, eomem >> 10);
   15.18  
   15.19 +    /* top of memory */
   15.20      max_page = PFN_DOWN(ALIGN_DOWN(eomem, PAGE_SIZE));
   15.21      total_pages = max_page;
   15.22  
   15.23 -    /* skip the exception handlers */
   15.24 +    /* Architecturally the first 4 pages are exception hendlers, we
   15.25 +     * will also be copying down some code there */
   15.26      heap_start = init_boot_allocator(4 << PAGE_SHIFT);
   15.27  
   15.28 +    /* we give the first RMA to the hypervisor */
   15.29 +    xenheap_phys_end = rma_size(cpu_rma_order());
   15.30 +
   15.31 +    /* allow everything else to be allocated */
   15.32 +    init_boot_pages(xenheap_phys_end, eomem);
   15.33 +    init_frametable();
   15.34 +    end_boot_allocator();
   15.35 +
   15.36 +    /* Add memory between the beginning of the heap and the beginning
   15.37 +     * of out text */
   15.38 +    init_xenheap_pages(heap_start, (ulong)_start);
   15.39 +
   15.40      /* move the modules to just after _end */
   15.41      if (modules_start) {
   15.42          printk("modules at: %016lx - %016lx\n", modules_start,
   15.43 @@ -293,27 +311,22 @@ static void __init __start_xen(multiboot
   15.44                  modules_start + modules_size);
   15.45      }
   15.46  
   15.47 +    /* the rest of the xenheap, starting at the end of modules */
   15.48 +    init_xenheap_pages(freemem, xenheap_phys_end);
   15.49 +
   15.50 +
   15.51  #ifdef OF_DEBUG
   15.52      printk("ofdump:\n");
   15.53      /* make sure the OF devtree is good */
   15.54      ofd_walk((void *)oftree, OFD_ROOT, ofd_dump_props, OFD_DUMP_ALL);
   15.55  #endif
   15.56  
   15.57 -    percpu_init_areas();
   15.58 -
   15.59 -    /* mark all memory from modules onward as unused */
   15.60 -    init_boot_pages(freemem, eomem);
   15.61 -
   15.62 -    init_frametable();
   15.63 -    end_boot_allocator();
   15.64 -
   15.65 -    /* place the heap from after the allocator bitmap to _start */
   15.66 -    xenheap_phys_end = (ulong)_start;
   15.67 -    init_xenheap_pages(heap_start, xenheap_phys_end);
   15.68      heap_size = xenheap_phys_end - heap_start;
   15.69  
   15.70      printk("Xen heap: %luMB (%lukB)\n", heap_size >> 20, heap_size >> 10);
   15.71  
   15.72 +    percpu_init_areas();
   15.73 +
   15.74      cpu_initialize();
   15.75  
   15.76  #ifdef CONFIG_GDB
    16.1 --- a/xen/include/asm-powerpc/config.h	Tue Aug 15 11:13:04 2006 +0100
    16.2 +++ b/xen/include/asm-powerpc/config.h	Tue Aug 15 11:16:46 2006 +0100
    16.3 @@ -47,6 +47,7 @@ extern char __bss_start[];
    16.4  /* this should be per processor, but for now */
    16.5  #define CACHE_LINE_SIZE 128
    16.6  
    16.7 +#define CONFIG_SHADOW 1
    16.8  #define CONFIG_GDB 1
    16.9  #define CONFIG_SMP 1
   16.10  #define CONFIG_PCI 1
    17.1 --- a/xen/include/asm-powerpc/domain.h	Tue Aug 15 11:13:04 2006 +0100
    17.2 +++ b/xen/include/asm-powerpc/domain.h	Tue Aug 15 11:16:46 2006 +0100
    17.3 @@ -32,10 +32,11 @@
    17.4  
    17.5  struct arch_domain {
    17.6      struct domain_htab htab;
    17.7 -    /* The RMO area is fixed to the domain and is accessible while the
    17.8 +
    17.9 +    /* The Real Mode area is fixed to the domain and is accessible while the
   17.10       * processor is in real mode */
   17.11 -    ulong rma_base;
   17.12 -    ulong rma_size;
   17.13 +    struct page_info *rma_page;
   17.14 +    uint rma_order;
   17.15  
   17.16      /* This is regular memory, only available thru translataion */
   17.17      ulong logical_base_pfn;
   17.18 @@ -106,9 +107,11 @@ extern void load_float(struct vcpu *);
   17.19  #define RMA_CONSOLE 3
   17.20  #define RMA_LAST_DOMU 3
   17.21  
   17.22 -static inline ulong rma_addr(struct arch_domain *d, int type)
   17.23 +#define rma_size(rma_order) (1UL << ((rma_order) + PAGE_SHIFT))
   17.24 +
   17.25 +static inline ulong rma_addr(struct arch_domain *ad, int type)
   17.26  {
   17.27 -    return d->rma_size - (type * PAGE_SIZE);
   17.28 +    return rma_size(ad->rma_order) - (type * PAGE_SIZE);
   17.29  }
   17.30  
   17.31  #endif
    18.1 --- a/xen/include/asm-powerpc/grant_table.h	Tue Aug 15 11:13:04 2006 +0100
    18.2 +++ b/xen/include/asm-powerpc/grant_table.h	Tue Aug 15 11:16:46 2006 +0100
    18.3 @@ -47,7 +47,7 @@ int destroy_grant_host_mapping(
    18.4  #define gnttab_shared_gmfn(d, t, i)                     \
    18.5      (mfn_to_gmfn(d, gnttab_shared_mfn(d, t, i)))
    18.6  
    18.7 -#define gnttab_log_dirty(d, f) ((void )0)
    18.8 +#define gnttab_log_dirty(d, f) mark_dirty((d), (f))
    18.9  
   18.10  static inline void gnttab_clear_flag(unsigned long nr, uint16_t *addr)
   18.11  {
    19.1 --- a/xen/include/asm-powerpc/htab.h	Tue Aug 15 11:13:04 2006 +0100
    19.2 +++ b/xen/include/asm-powerpc/htab.h	Tue Aug 15 11:16:46 2006 +0100
    19.3 @@ -26,9 +26,6 @@
    19.4  
    19.5  /***** general PowerPC architecture limits ******/
    19.6  
    19.7 -#define LOG_DEFAULT_HTAB_BYTES  20
    19.8 -#define DEFAULT_HTAB_BYTES      (1UL << LOG_HTAB_BYTES)
    19.9 -
   19.10  /* 256KB, from PowerPC Architecture specification */
   19.11  #define HTAB_MIN_LOG_SIZE 18
   19.12  
   19.13 @@ -131,12 +128,13 @@ union ptel {
   19.14  
   19.15  struct domain_htab {
   19.16      ulong sdr1;
   19.17 -    ulong log_num_ptes; /* log number of PTEs in HTAB. */
   19.18 +    uint log_num_ptes;  /* log number of PTEs in HTAB. */
   19.19 +    uint order;         /* order for freeing. */
   19.20      union pte *map;     /* access the htab like an array */
   19.21      ulong *shadow;      /* idx -> logical translation array */
   19.22  };
   19.23  
   19.24  struct domain;
   19.25 -extern void htab_alloc(struct domain *d, int log_htab_bytes);
   19.26 +extern void htab_alloc(struct domain *d, uint order);
   19.27  extern void htab_free(struct domain *d);
   19.28  #endif
    20.1 --- a/xen/include/asm-powerpc/mm.h	Tue Aug 15 11:13:04 2006 +0100
    20.2 +++ b/xen/include/asm-powerpc/mm.h	Tue Aug 15 11:16:46 2006 +0100
    20.3 @@ -33,7 +33,7 @@
    20.4  #define memguard_unguard_range(_p,_l)    ((void)0)
    20.5  
    20.6  extern unsigned long xenheap_phys_end;
    20.7 -#define IS_XEN_HEAP_FRAME(_pfn) (page_to_mfn(_pfn) < xenheap_phys_end)
    20.8 +#define IS_XEN_HEAP_FRAME(_pfn) (page_to_maddr(_pfn) < xenheap_phys_end)
    20.9  
   20.10  /*
   20.11   * Per-page-frame information.
    21.1 --- a/xen/include/asm-powerpc/shadow.h	Tue Aug 15 11:13:04 2006 +0100
    21.2 +++ b/xen/include/asm-powerpc/shadow.h	Tue Aug 15 11:16:46 2006 +0100
    21.3 @@ -23,7 +23,8 @@
    21.4  
    21.5  #include <xen/sched.h>
    21.6  
    21.7 -#define shadow_mode_translate(_d) 1
    21.8 +#define shadow_mode_translate(_d) (1)
    21.9 +#define shadow_mode_refcounts(_d) (1)
   21.10  
   21.11  #define __translate_gpfn_to_mfn(_d, gpfn)              \
   21.12      ( (shadow_mode_translate(_d))                      \
   21.13 @@ -41,5 +42,17 @@ translate_gpfn_to_mfn(struct domain *rd,
   21.14      trap();
   21.15      return 0;
   21.16  }
   21.17 +extern void guest_physmap_add_page(
   21.18 +    struct domain *d, unsigned long gpfn, unsigned long mfn);
   21.19  
   21.20 +extern void guest_physmap_remove_page(
   21.21 +    struct domain *d, unsigned long gpfn, unsigned long mfn);
   21.22 +
   21.23 +extern void shadow_drop_references(
   21.24 +    struct domain *d, struct page_info *page);
   21.25 +
   21.26 +static inline void mark_dirty(struct domain *d, unsigned int mfn)
   21.27 +{
   21.28 +    return;
   21.29 +}
   21.30  #endif