aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@g5.osdl.org>2005-09-12 11:33:53 -0400
committerLinus Torvalds <torvalds@g5.osdl.org>2005-09-12 11:33:53 -0400
commit26cda988ba1e3e843a0680fe98661a22fa430a60 (patch)
tree692e76e9bc9b11ed34bad88f892adc0184c2e5ff
parent1df5c10a5b40d1ad747e3de3caf28764153c5c8e (diff)
parent2d909d08db7655a53f3afb31c7627c5c8c87142a (diff)
Merge master.kernel.org:/pub/scm/linux/kernel/git/paulus/ppc64-2.6
-rw-r--r--arch/ppc64/kernel/iSeries_pci.c2
-rw-r--r--arch/ppc64/kernel/maple_pci.c56
-rw-r--r--arch/ppc64/kernel/pSeries_setup.c8
-rw-r--r--arch/ppc64/kernel/pSeries_smp.c13
-rw-r--r--arch/ppc64/kernel/pci.c425
-rw-r--r--arch/ppc64/kernel/pmac_pci.c60
-rw-r--r--arch/ppc64/kernel/pmac_setup.c13
-rw-r--r--arch/ppc64/kernel/process.c34
-rw-r--r--arch/ppc64/kernel/ptrace.c28
-rw-r--r--arch/ppc64/kernel/ptrace32.c34
-rw-r--r--arch/ppc64/kernel/ras.c2
-rw-r--r--arch/ppc64/kernel/setup.c16
-rw-r--r--arch/ppc64/kernel/signal.c9
-rw-r--r--arch/ppc64/kernel/signal32.c8
-rw-r--r--arch/ppc64/kernel/xics.c44
-rw-r--r--arch/ppc64/mm/fault.c31
-rw-r--r--arch/ppc64/xmon/privinst.h1
-rw-r--r--arch/ppc64/xmon/xmon.c20
-rw-r--r--include/asm-powerpc/siginfo.h8
-rw-r--r--include/asm-ppc/ptrace.h7
-rw-r--r--include/asm-ppc64/hvcall.h6
-rw-r--r--include/asm-ppc64/machdep.h5
-rw-r--r--include/asm-ppc64/pci-bridge.h5
-rw-r--r--include/asm-ppc64/plpar_wrappers.h9
-rw-r--r--include/asm-ppc64/processor.h1
-rw-r--r--include/asm-ppc64/ptrace-common.h92
-rw-r--r--include/asm-ppc64/ptrace.h128
-rw-r--r--include/asm-ppc64/system.h3
28 files changed, 795 insertions, 273 deletions
diff --git a/arch/ppc64/kernel/iSeries_pci.c b/arch/ppc64/kernel/iSeries_pci.c
index 356e4fd9a94f..fbc273c32bcc 100644
--- a/arch/ppc64/kernel/iSeries_pci.c
+++ b/arch/ppc64/kernel/iSeries_pci.c
@@ -252,7 +252,7 @@ unsigned long __init find_and_init_phbs(void)
252 phb = (struct pci_controller *)kmalloc(sizeof(struct pci_controller), GFP_KERNEL); 252 phb = (struct pci_controller *)kmalloc(sizeof(struct pci_controller), GFP_KERNEL);
253 if (phb == NULL) 253 if (phb == NULL)
254 return -ENOMEM; 254 return -ENOMEM;
255 pci_setup_pci_controller(phb); 255 pci_setup_pci_controller(phb);
256 256
257 phb->pci_mem_offset = phb->local_number = bus; 257 phb->pci_mem_offset = phb->local_number = bus;
258 phb->first_busno = bus; 258 phb->first_busno = bus;
diff --git a/arch/ppc64/kernel/maple_pci.c b/arch/ppc64/kernel/maple_pci.c
index 5a8b4d8c2dd6..1d297e0edfc0 100644
--- a/arch/ppc64/kernel/maple_pci.c
+++ b/arch/ppc64/kernel/maple_pci.c
@@ -283,7 +283,7 @@ static void __init setup_u3_agp(struct pci_controller* hose)
283 * the reg address cell, we shall fix that by killing struct 283 * the reg address cell, we shall fix that by killing struct
284 * reg_property and using some accessor functions instead 284 * reg_property and using some accessor functions instead
285 */ 285 */
286 hose->first_busno = 0xf0; 286 hose->first_busno = 0xf0;
287 hose->last_busno = 0xff; 287 hose->last_busno = 0xff;
288 hose->ops = &u3_agp_pci_ops; 288 hose->ops = &u3_agp_pci_ops;
289 hose->cfg_addr = ioremap(0xf0000000 + 0x800000, 0x1000); 289 hose->cfg_addr = ioremap(0xf0000000 + 0x800000, 0x1000);
@@ -315,24 +315,24 @@ static int __init add_bridge(struct device_node *dev)
315 char* disp_name; 315 char* disp_name;
316 int *bus_range; 316 int *bus_range;
317 int primary = 1; 317 int primary = 1;
318 struct property *of_prop; 318 struct property *of_prop;
319 319
320 DBG("Adding PCI host bridge %s\n", dev->full_name); 320 DBG("Adding PCI host bridge %s\n", dev->full_name);
321 321
322 bus_range = (int *) get_property(dev, "bus-range", &len); 322 bus_range = (int *) get_property(dev, "bus-range", &len);
323 if (bus_range == NULL || len < 2 * sizeof(int)) { 323 if (bus_range == NULL || len < 2 * sizeof(int)) {
324 printk(KERN_WARNING "Can't get bus-range for %s, assume bus 0\n", 324 printk(KERN_WARNING "Can't get bus-range for %s, assume bus 0\n",
325 dev->full_name); 325 dev->full_name);
326 } 326 }
327 327
328 hose = alloc_bootmem(sizeof(struct pci_controller)); 328 hose = alloc_bootmem(sizeof(struct pci_controller));
329 if (hose == NULL) 329 if (hose == NULL)
330 return -ENOMEM; 330 return -ENOMEM;
331 pci_setup_pci_controller(hose); 331 pci_setup_pci_controller(hose);
332 332
333 hose->arch_data = dev; 333 hose->arch_data = dev;
334 hose->first_busno = bus_range ? bus_range[0] : 0; 334 hose->first_busno = bus_range ? bus_range[0] : 0;
335 hose->last_busno = bus_range ? bus_range[1] : 0xff; 335 hose->last_busno = bus_range ? bus_range[1] : 0xff;
336 336
337 of_prop = alloc_bootmem(sizeof(struct property) + 337 of_prop = alloc_bootmem(sizeof(struct property) +
338 sizeof(hose->global_number)); 338 sizeof(hose->global_number));
@@ -346,25 +346,25 @@ static int __init add_bridge(struct device_node *dev)
346 } 346 }
347 347
348 disp_name = NULL; 348 disp_name = NULL;
349 if (device_is_compatible(dev, "u3-agp")) { 349 if (device_is_compatible(dev, "u3-agp")) {
350 setup_u3_agp(hose); 350 setup_u3_agp(hose);
351 disp_name = "U3-AGP"; 351 disp_name = "U3-AGP";
352 primary = 0; 352 primary = 0;
353 } else if (device_is_compatible(dev, "u3-ht")) { 353 } else if (device_is_compatible(dev, "u3-ht")) {
354 setup_u3_ht(hose); 354 setup_u3_ht(hose);
355 disp_name = "U3-HT"; 355 disp_name = "U3-HT";
356 primary = 1; 356 primary = 1;
357 } 357 }
358 printk(KERN_INFO "Found %s PCI host bridge. Firmware bus number: %d->%d\n", 358 printk(KERN_INFO "Found %s PCI host bridge. Firmware bus number: %d->%d\n",
359 disp_name, hose->first_busno, hose->last_busno); 359 disp_name, hose->first_busno, hose->last_busno);
360 360
361 /* Interpret the "ranges" property */ 361 /* Interpret the "ranges" property */
362 /* This also maps the I/O region and sets isa_io/mem_base */ 362 /* This also maps the I/O region and sets isa_io/mem_base */
363 pci_process_bridge_OF_ranges(hose, dev); 363 pci_process_bridge_OF_ranges(hose, dev);
364 pci_setup_phb_io(hose, primary); 364 pci_setup_phb_io(hose, primary);
365 365
366 /* Fixup "bus-range" OF property */ 366 /* Fixup "bus-range" OF property */
367 fixup_bus_range(dev); 367 fixup_bus_range(dev);
368 368
369 return 0; 369 return 0;
370} 370}
diff --git a/arch/ppc64/kernel/pSeries_setup.c b/arch/ppc64/kernel/pSeries_setup.c
index 9490b6c5b173..bfadccc7b8be 100644
--- a/arch/ppc64/kernel/pSeries_setup.c
+++ b/arch/ppc64/kernel/pSeries_setup.c
@@ -590,6 +590,13 @@ static int pseries_shared_idle(void)
590 return 0; 590 return 0;
591} 591}
592 592
593static int pSeries_pci_probe_mode(struct pci_bus *bus)
594{
595 if (systemcfg->platform & PLATFORM_LPAR)
596 return PCI_PROBE_DEVTREE;
597 return PCI_PROBE_NORMAL;
598}
599
593struct machdep_calls __initdata pSeries_md = { 600struct machdep_calls __initdata pSeries_md = {
594 .probe = pSeries_probe, 601 .probe = pSeries_probe,
595 .setup_arch = pSeries_setup_arch, 602 .setup_arch = pSeries_setup_arch,
@@ -597,6 +604,7 @@ struct machdep_calls __initdata pSeries_md = {
597 .get_cpuinfo = pSeries_get_cpuinfo, 604 .get_cpuinfo = pSeries_get_cpuinfo,
598 .log_error = pSeries_log_error, 605 .log_error = pSeries_log_error,
599 .pcibios_fixup = pSeries_final_fixup, 606 .pcibios_fixup = pSeries_final_fixup,
607 .pci_probe_mode = pSeries_pci_probe_mode,
600 .irq_bus_setup = pSeries_irq_bus_setup, 608 .irq_bus_setup = pSeries_irq_bus_setup,
601 .restart = rtas_restart, 609 .restart = rtas_restart,
602 .power_off = rtas_power_off, 610 .power_off = rtas_power_off,
diff --git a/arch/ppc64/kernel/pSeries_smp.c b/arch/ppc64/kernel/pSeries_smp.c
index 79c7f3223665..d2c7e2c4733b 100644
--- a/arch/ppc64/kernel/pSeries_smp.c
+++ b/arch/ppc64/kernel/pSeries_smp.c
@@ -272,6 +272,7 @@ static inline int __devinit smp_startup_cpu(unsigned int lcpu)
272 unsigned long start_here = __pa((u32)*((unsigned long *) 272 unsigned long start_here = __pa((u32)*((unsigned long *)
273 pSeries_secondary_smp_init)); 273 pSeries_secondary_smp_init));
274 unsigned int pcpu; 274 unsigned int pcpu;
275 int start_cpu;
275 276
276 if (cpu_isset(lcpu, of_spin_map)) 277 if (cpu_isset(lcpu, of_spin_map))
277 /* Already started by OF and sitting in spin loop */ 278 /* Already started by OF and sitting in spin loop */
@@ -282,12 +283,20 @@ static inline int __devinit smp_startup_cpu(unsigned int lcpu)
282 /* Fixup atomic count: it exited inside IRQ handler. */ 283 /* Fixup atomic count: it exited inside IRQ handler. */
283 paca[lcpu].__current->thread_info->preempt_count = 0; 284 paca[lcpu].__current->thread_info->preempt_count = 0;
284 285
285 status = rtas_call(rtas_token("start-cpu"), 3, 1, NULL, 286 /*
286 pcpu, start_here, lcpu); 287 * If the RTAS start-cpu token does not exist then presume the
288 * cpu is already spinning.
289 */
290 start_cpu = rtas_token("start-cpu");
291 if (start_cpu == RTAS_UNKNOWN_SERVICE)
292 return 1;
293
294 status = rtas_call(start_cpu, 3, 1, NULL, pcpu, start_here, lcpu);
287 if (status != 0) { 295 if (status != 0) {
288 printk(KERN_ERR "start-cpu failed: %i\n", status); 296 printk(KERN_ERR "start-cpu failed: %i\n", status);
289 return 0; 297 return 0;
290 } 298 }
299
291 return 1; 300 return 1;
292} 301}
293 302
diff --git a/arch/ppc64/kernel/pci.c b/arch/ppc64/kernel/pci.c
index 8447dcc2c2b3..861138ad092c 100644
--- a/arch/ppc64/kernel/pci.c
+++ b/arch/ppc64/kernel/pci.c
@@ -51,6 +51,10 @@ unsigned long io_page_mask;
51 51
52EXPORT_SYMBOL(io_page_mask); 52EXPORT_SYMBOL(io_page_mask);
53 53
54#ifdef CONFIG_PPC_MULTIPLATFORM
55static void fixup_resource(struct resource *res, struct pci_dev *dev);
56static void do_bus_setup(struct pci_bus *bus);
57#endif
54 58
55unsigned int pcibios_assign_all_busses(void) 59unsigned int pcibios_assign_all_busses(void)
56{ 60{
@@ -225,10 +229,287 @@ static void __init pcibios_claim_of_setup(void)
225} 229}
226#endif 230#endif
227 231
232#ifdef CONFIG_PPC_MULTIPLATFORM
233static u32 get_int_prop(struct device_node *np, const char *name, u32 def)
234{
235 u32 *prop;
236 int len;
237
238 prop = (u32 *) get_property(np, name, &len);
239 if (prop && len >= 4)
240 return *prop;
241 return def;
242}
243
244static unsigned int pci_parse_of_flags(u32 addr0)
245{
246 unsigned int flags = 0;
247
248 if (addr0 & 0x02000000) {
249 flags |= IORESOURCE_MEM;
250 if (addr0 & 0x40000000)
251 flags |= IORESOURCE_PREFETCH;
252 } else if (addr0 & 0x01000000)
253 flags |= IORESOURCE_IO;
254 return flags;
255}
256
257#define GET_64BIT(prop, i) ((((u64) (prop)[(i)]) << 32) | (prop)[(i)+1])
258
259static void pci_parse_of_addrs(struct device_node *node, struct pci_dev *dev)
260{
261 u64 base, size;
262 unsigned int flags;
263 struct resource *res;
264 u32 *addrs, i;
265 int proplen;
266
267 addrs = (u32 *) get_property(node, "assigned-addresses", &proplen);
268 if (!addrs)
269 return;
270 for (; proplen >= 20; proplen -= 20, addrs += 5) {
271 flags = pci_parse_of_flags(addrs[0]);
272 if (!flags)
273 continue;
274 base = GET_64BIT(addrs, 1);
275 size = GET_64BIT(addrs, 3);
276 if (!size)
277 continue;
278 i = addrs[0] & 0xff;
279 if (PCI_BASE_ADDRESS_0 <= i && i <= PCI_BASE_ADDRESS_5) {
280 res = &dev->resource[(i - PCI_BASE_ADDRESS_0) >> 2];
281 } else if (i == dev->rom_base_reg) {
282 res = &dev->resource[PCI_ROM_RESOURCE];
283 flags |= IORESOURCE_READONLY | IORESOURCE_CACHEABLE;
284 } else {
285 printk(KERN_ERR "PCI: bad cfg reg num 0x%x\n", i);
286 continue;
287 }
288 res->start = base;
289 res->end = base + size - 1;
290 res->flags = flags;
291 res->name = pci_name(dev);
292 fixup_resource(res, dev);
293 }
294}
295
296static struct pci_dev *of_create_pci_dev(struct device_node *node,
297 struct pci_bus *bus, int devfn)
298{
299 struct pci_dev *dev;
300 const char *type;
301
302 dev = kmalloc(sizeof(struct pci_dev), GFP_KERNEL);
303 if (!dev)
304 return NULL;
305 type = get_property(node, "device_type", NULL);
306 if (type == NULL)
307 type = "";
308
309 memset(dev, 0, sizeof(struct pci_dev));
310 dev->bus = bus;
311 dev->sysdata = node;
312 dev->dev.parent = bus->bridge;
313 dev->dev.bus = &pci_bus_type;
314 dev->devfn = devfn;
315 dev->multifunction = 0; /* maybe a lie? */
316
317 dev->vendor = get_int_prop(node, "vendor-id", 0xffff);
318 dev->device = get_int_prop(node, "device-id", 0xffff);
319 dev->subsystem_vendor = get_int_prop(node, "subsystem-vendor-id", 0);
320 dev->subsystem_device = get_int_prop(node, "subsystem-id", 0);
321
322 dev->cfg_size = 256; /*pci_cfg_space_size(dev);*/
323
324 sprintf(pci_name(dev), "%04x:%02x:%02x.%d", pci_domain_nr(bus),
325 dev->bus->number, PCI_SLOT(devfn), PCI_FUNC(devfn));
326 dev->class = get_int_prop(node, "class-code", 0);
327
328 dev->current_state = 4; /* unknown power state */
329
330 if (!strcmp(type, "pci")) {
331 /* a PCI-PCI bridge */
332 dev->hdr_type = PCI_HEADER_TYPE_BRIDGE;
333 dev->rom_base_reg = PCI_ROM_ADDRESS1;
334 } else if (!strcmp(type, "cardbus")) {
335 dev->hdr_type = PCI_HEADER_TYPE_CARDBUS;
336 } else {
337 dev->hdr_type = PCI_HEADER_TYPE_NORMAL;
338 dev->rom_base_reg = PCI_ROM_ADDRESS;
339 dev->irq = NO_IRQ;
340 if (node->n_intrs > 0) {
341 dev->irq = node->intrs[0].line;
342 pci_write_config_byte(dev, PCI_INTERRUPT_LINE,
343 dev->irq);
344 }
345 }
346
347 pci_parse_of_addrs(node, dev);
348
349 pci_device_add(dev, bus);
350
351 /* XXX pci_scan_msi_device(dev); */
352
353 return dev;
354}
355
356static void of_scan_pci_bridge(struct device_node *node, struct pci_dev *dev);
357
358static void __devinit of_scan_bus(struct device_node *node,
359 struct pci_bus *bus)
360{
361 struct device_node *child = NULL;
362 u32 *reg;
363 int reglen, devfn;
364 struct pci_dev *dev;
365
366 while ((child = of_get_next_child(node, child)) != NULL) {
367 reg = (u32 *) get_property(child, "reg", &reglen);
368 if (reg == NULL || reglen < 20)
369 continue;
370 devfn = (reg[0] >> 8) & 0xff;
371 /* create a new pci_dev for this device */
372 dev = of_create_pci_dev(child, bus, devfn);
373 if (!dev)
374 continue;
375 if (dev->hdr_type == PCI_HEADER_TYPE_BRIDGE ||
376 dev->hdr_type == PCI_HEADER_TYPE_CARDBUS)
377 of_scan_pci_bridge(child, dev);
378 }
379
380 do_bus_setup(bus);
381}
382
383static void __devinit of_scan_pci_bridge(struct device_node *node,
384 struct pci_dev *dev)
385{
386 struct pci_bus *bus;
387 u32 *busrange, *ranges;
388 int len, i, mode;
389 struct resource *res;
390 unsigned int flags;
391 u64 size;
392
393 /* parse bus-range property */
394 busrange = (u32 *) get_property(node, "bus-range", &len);
395 if (busrange == NULL || len != 8) {
396 printk(KERN_ERR "Can't get bus-range for PCI-PCI bridge %s\n",
397 node->full_name);
398 return;
399 }
400 ranges = (u32 *) get_property(node, "ranges", &len);
401 if (ranges == NULL) {
402 printk(KERN_ERR "Can't get ranges for PCI-PCI bridge %s\n",
403 node->full_name);
404 return;
405 }
406
407 bus = pci_add_new_bus(dev->bus, dev, busrange[0]);
408 if (!bus) {
409 printk(KERN_ERR "Failed to create pci bus for %s\n",
410 node->full_name);
411 return;
412 }
413
414 bus->primary = dev->bus->number;
415 bus->subordinate = busrange[1];
416 bus->bridge_ctl = 0;
417 bus->sysdata = node;
418
419 /* parse ranges property */
420 /* PCI #address-cells == 3 and #size-cells == 2 always */
421 res = &dev->resource[PCI_BRIDGE_RESOURCES];
422 for (i = 0; i < PCI_NUM_RESOURCES - PCI_BRIDGE_RESOURCES; ++i) {
423 res->flags = 0;
424 bus->resource[i] = res;
425 ++res;
426 }
427 i = 1;
428 for (; len >= 32; len -= 32, ranges += 8) {
429 flags = pci_parse_of_flags(ranges[0]);
430 size = GET_64BIT(ranges, 6);
431 if (flags == 0 || size == 0)
432 continue;
433 if (flags & IORESOURCE_IO) {
434 res = bus->resource[0];
435 if (res->flags) {
436 printk(KERN_ERR "PCI: ignoring extra I/O range"
437 " for bridge %s\n", node->full_name);
438 continue;
439 }
440 } else {
441 if (i >= PCI_NUM_RESOURCES - PCI_BRIDGE_RESOURCES) {
442 printk(KERN_ERR "PCI: too many memory ranges"
443 " for bridge %s\n", node->full_name);
444 continue;
445 }
446 res = bus->resource[i];
447 ++i;
448 }
449 res->start = GET_64BIT(ranges, 1);
450 res->end = res->start + size - 1;
451 res->flags = flags;
452 fixup_resource(res, dev);
453 }
454 sprintf(bus->name, "PCI Bus %04x:%02x", pci_domain_nr(bus),
455 bus->number);
456
457 mode = PCI_PROBE_NORMAL;
458 if (ppc_md.pci_probe_mode)
459 mode = ppc_md.pci_probe_mode(bus);
460 if (mode == PCI_PROBE_DEVTREE)
461 of_scan_bus(node, bus);
462 else if (mode == PCI_PROBE_NORMAL)
463 pci_scan_child_bus(bus);
464}
465#endif /* CONFIG_PPC_MULTIPLATFORM */
466
467static void __devinit scan_phb(struct pci_controller *hose)
468{
469 struct pci_bus *bus;
470 struct device_node *node = hose->arch_data;
471 int i, mode;
472 struct resource *res;
473
474 bus = pci_create_bus(NULL, hose->first_busno, hose->ops, node);
475 if (bus == NULL) {
476 printk(KERN_ERR "Failed to create bus for PCI domain %04x\n",
477 hose->global_number);
478 return;
479 }
480 bus->secondary = hose->first_busno;
481 hose->bus = bus;
482
483 bus->resource[0] = res = &hose->io_resource;
484 if (res->flags && request_resource(&ioport_resource, res))
485 printk(KERN_ERR "Failed to request PCI IO region "
486 "on PCI domain %04x\n", hose->global_number);
487
488 for (i = 0; i < 3; ++i) {
489 res = &hose->mem_resources[i];
490 bus->resource[i+1] = res;
491 if (res->flags && request_resource(&iomem_resource, res))
492 printk(KERN_ERR "Failed to request PCI memory region "
493 "on PCI domain %04x\n", hose->global_number);
494 }
495
496 mode = PCI_PROBE_NORMAL;
497#ifdef CONFIG_PPC_MULTIPLATFORM
498 if (ppc_md.pci_probe_mode)
499 mode = ppc_md.pci_probe_mode(bus);
500 if (mode == PCI_PROBE_DEVTREE) {
501 bus->subordinate = hose->last_busno;
502 of_scan_bus(node, bus);
503 }
504#endif /* CONFIG_PPC_MULTIPLATFORM */
505 if (mode == PCI_PROBE_NORMAL)
506 hose->last_busno = bus->subordinate = pci_scan_child_bus(bus);
507 pci_bus_add_devices(bus);
508}
509
228static int __init pcibios_init(void) 510static int __init pcibios_init(void)
229{ 511{
230 struct pci_controller *hose, *tmp; 512 struct pci_controller *hose, *tmp;
231 struct pci_bus *bus;
232 513
233 /* For now, override phys_mem_access_prot. If we need it, 514 /* For now, override phys_mem_access_prot. If we need it,
234 * later, we may move that initialization to each ppc_md 515 * later, we may move that initialization to each ppc_md
@@ -242,13 +523,8 @@ static int __init pcibios_init(void)
242 printk("PCI: Probing PCI hardware\n"); 523 printk("PCI: Probing PCI hardware\n");
243 524
244 /* Scan all of the recorded PCI controllers. */ 525 /* Scan all of the recorded PCI controllers. */
245 list_for_each_entry_safe(hose, tmp, &hose_list, list_node) { 526 list_for_each_entry_safe(hose, tmp, &hose_list, list_node)
246 hose->last_busno = 0xff; 527 scan_phb(hose);
247 bus = pci_scan_bus(hose->first_busno, hose->ops,
248 hose->arch_data);
249 hose->bus = bus;
250 hose->last_busno = bus->subordinate;
251 }
252 528
253#ifndef CONFIG_PPC_ISERIES 529#ifndef CONFIG_PPC_ISERIES
254 if (pci_probe_only) 530 if (pci_probe_only)
@@ -820,120 +1096,89 @@ void phbs_remap_io(void)
820/* 1096/*
821 * ppc64 can have multifunction devices that do not respond to function 0. 1097 * ppc64 can have multifunction devices that do not respond to function 0.
822 * In this case we must scan all functions. 1098 * In this case we must scan all functions.
1099 * XXX this can go now, we use the OF device tree in all the
1100 * cases that caused problems. -- paulus
823 */ 1101 */
824int pcibios_scan_all_fns(struct pci_bus *bus, int devfn) 1102int pcibios_scan_all_fns(struct pci_bus *bus, int devfn)
825{ 1103{
826 struct device_node *busdn, *dn;
827
828 if (bus->self)
829 busdn = pci_device_to_OF_node(bus->self);
830 else
831 busdn = bus->sysdata; /* must be a phb */
832
833 if (busdn == NULL)
834 return 0;
835
836 /*
837 * Check to see if there is any of the 8 functions are in the
838 * device tree. If they are then we need to scan all the
839 * functions of this slot.
840 */
841 for (dn = busdn->child; dn; dn = dn->sibling) {
842 struct pci_dn *pdn = dn->data;
843 if (pdn && (pdn->devfn >> 3) == (devfn >> 3))
844 return 1;
845 }
846
847 return 0; 1104 return 0;
848} 1105}
849 1106
1107static void __devinit fixup_resource(struct resource *res, struct pci_dev *dev)
1108{
1109 struct pci_controller *hose = pci_bus_to_host(dev->bus);
1110 unsigned long start, end, mask, offset;
1111
1112 if (res->flags & IORESOURCE_IO) {
1113 offset = (unsigned long)hose->io_base_virt - pci_io_base;
1114
1115 start = res->start += offset;
1116 end = res->end += offset;
1117
1118 /* Need to allow IO access to pages that are in the
1119 ISA range */
1120 if (start < MAX_ISA_PORT) {
1121 if (end > MAX_ISA_PORT)
1122 end = MAX_ISA_PORT;
1123
1124 start >>= PAGE_SHIFT;
1125 end >>= PAGE_SHIFT;
1126
1127 /* get the range of pages for the map */
1128 mask = ((1 << (end+1)) - 1) ^ ((1 << start) - 1);
1129 io_page_mask |= mask;
1130 }
1131 } else if (res->flags & IORESOURCE_MEM) {
1132 res->start += hose->pci_mem_offset;
1133 res->end += hose->pci_mem_offset;
1134 }
1135}
850 1136
851void __devinit pcibios_fixup_device_resources(struct pci_dev *dev, 1137void __devinit pcibios_fixup_device_resources(struct pci_dev *dev,
852 struct pci_bus *bus) 1138 struct pci_bus *bus)
853{ 1139{
854 /* Update device resources. */ 1140 /* Update device resources. */
855 struct pci_controller *hose = pci_bus_to_host(bus);
856 int i; 1141 int i;
857 1142
858 for (i = 0; i < PCI_NUM_RESOURCES; i++) { 1143 for (i = 0; i < PCI_NUM_RESOURCES; i++)
859 if (dev->resource[i].flags & IORESOURCE_IO) { 1144 if (dev->resource[i].flags)
860 unsigned long offset = (unsigned long)hose->io_base_virt 1145 fixup_resource(&dev->resource[i], dev);
861 - pci_io_base;
862 unsigned long start, end, mask;
863
864 start = dev->resource[i].start += offset;
865 end = dev->resource[i].end += offset;
866
867 /* Need to allow IO access to pages that are in the
868 ISA range */
869 if (start < MAX_ISA_PORT) {
870 if (end > MAX_ISA_PORT)
871 end = MAX_ISA_PORT;
872
873 start >>= PAGE_SHIFT;
874 end >>= PAGE_SHIFT;
875
876 /* get the range of pages for the map */
877 mask = ((1 << (end+1))-1) ^ ((1 << start)-1);
878 io_page_mask |= mask;
879 }
880 }
881 else if (dev->resource[i].flags & IORESOURCE_MEM) {
882 dev->resource[i].start += hose->pci_mem_offset;
883 dev->resource[i].end += hose->pci_mem_offset;
884 }
885 }
886} 1146}
887EXPORT_SYMBOL(pcibios_fixup_device_resources); 1147EXPORT_SYMBOL(pcibios_fixup_device_resources);
888 1148
889void __devinit pcibios_fixup_bus(struct pci_bus *bus) 1149static void __devinit do_bus_setup(struct pci_bus *bus)
890{ 1150{
891 struct pci_controller *hose = pci_bus_to_host(bus); 1151 struct pci_dev *dev;
892 struct pci_dev *dev = bus->self;
893 struct resource *res;
894 int i;
895 1152
896 if (!dev) { 1153 ppc_md.iommu_bus_setup(bus);
897 /* Root bus. */
898 1154
899 hose->bus = bus; 1155 list_for_each_entry(dev, &bus->devices, bus_list)
900 bus->resource[0] = res = &hose->io_resource; 1156 ppc_md.iommu_dev_setup(dev);
901 1157
902 if (res->flags && request_resource(&ioport_resource, res)) 1158 if (ppc_md.irq_bus_setup)
903 printk(KERN_ERR "Failed to request IO on " 1159 ppc_md.irq_bus_setup(bus);
904 "PCI domain %d\n", pci_domain_nr(bus)); 1160}
905 1161
906 for (i = 0; i < 3; ++i) { 1162void __devinit pcibios_fixup_bus(struct pci_bus *bus)
907 res = &hose->mem_resources[i]; 1163{
908 bus->resource[i+1] = res; 1164 struct pci_dev *dev = bus->self;
909 if (res->flags && request_resource(&iomem_resource, res)) 1165
910 printk(KERN_ERR "Failed to request MEM on " 1166 if (dev && pci_probe_only &&
911 "PCI domain %d\n", 1167 (dev->class >> 8) == PCI_CLASS_BRIDGE_PCI) {
912 pci_domain_nr(bus));
913 }
914 } else if (pci_probe_only &&
915 (dev->class >> 8) == PCI_CLASS_BRIDGE_PCI) {
916 /* This is a subordinate bridge */ 1168 /* This is a subordinate bridge */
917 1169
918 pci_read_bridge_bases(bus); 1170 pci_read_bridge_bases(bus);
919 pcibios_fixup_device_resources(dev, bus); 1171 pcibios_fixup_device_resources(dev, bus);
920 } 1172 }
921 1173
922 ppc_md.iommu_bus_setup(bus); 1174 do_bus_setup(bus);
923
924 list_for_each_entry(dev, &bus->devices, bus_list)
925 ppc_md.iommu_dev_setup(dev);
926
927 if (ppc_md.irq_bus_setup)
928 ppc_md.irq_bus_setup(bus);
929 1175
930 if (!pci_probe_only) 1176 if (!pci_probe_only)
931 return; 1177 return;
932 1178
933 list_for_each_entry(dev, &bus->devices, bus_list) { 1179 list_for_each_entry(dev, &bus->devices, bus_list)
934 if ((dev->class >> 8) != PCI_CLASS_BRIDGE_PCI) 1180 if ((dev->class >> 8) != PCI_CLASS_BRIDGE_PCI)
935 pcibios_fixup_device_resources(dev, bus); 1181 pcibios_fixup_device_resources(dev, bus);
936 }
937} 1182}
938EXPORT_SYMBOL(pcibios_fixup_bus); 1183EXPORT_SYMBOL(pcibios_fixup_bus);
939 1184
diff --git a/arch/ppc64/kernel/pmac_pci.c b/arch/ppc64/kernel/pmac_pci.c
index d37bff2d7d40..dc40a0cad0b4 100644
--- a/arch/ppc64/kernel/pmac_pci.c
+++ b/arch/ppc64/kernel/pmac_pci.c
@@ -388,7 +388,7 @@ static void __init setup_u3_agp(struct pci_controller* hose)
388 * the reg address cell, we shall fix that by killing struct 388 * the reg address cell, we shall fix that by killing struct
389 * reg_property and using some accessor functions instead 389 * reg_property and using some accessor functions instead
390 */ 390 */
391 hose->first_busno = 0xf0; 391 hose->first_busno = 0xf0;
392 hose->last_busno = 0xff; 392 hose->last_busno = 0xff;
393 has_uninorth = 1; 393 has_uninorth = 1;
394 hose->ops = &macrisc_pci_ops; 394 hose->ops = &macrisc_pci_ops;
@@ -473,7 +473,7 @@ static void __init setup_u3_ht(struct pci_controller* hose)
473 continue; 473 continue;
474 } 474 }
475 cur++; 475 cur++;
476 DBG("U3/HT: hole, %d end at %08lx, %d start at %08lx\n", 476 DBG("U3/HT: hole, %d end at %08lx, %d start at %08lx\n",
477 cur-1, res->start - 1, cur, res->end + 1); 477 cur-1, res->start - 1, cur, res->end + 1);
478 hose->mem_resources[cur].name = np->full_name; 478 hose->mem_resources[cur].name = np->full_name;
479 hose->mem_resources[cur].flags = IORESOURCE_MEM; 479 hose->mem_resources[cur].flags = IORESOURCE_MEM;
@@ -603,24 +603,24 @@ static int __init add_bridge(struct device_node *dev)
603 char* disp_name; 603 char* disp_name;
604 int *bus_range; 604 int *bus_range;
605 int primary = 1; 605 int primary = 1;
606 struct property *of_prop; 606 struct property *of_prop;
607 607
608 DBG("Adding PCI host bridge %s\n", dev->full_name); 608 DBG("Adding PCI host bridge %s\n", dev->full_name);
609 609
610 bus_range = (int *) get_property(dev, "bus-range", &len); 610 bus_range = (int *) get_property(dev, "bus-range", &len);
611 if (bus_range == NULL || len < 2 * sizeof(int)) { 611 if (bus_range == NULL || len < 2 * sizeof(int)) {
612 printk(KERN_WARNING "Can't get bus-range for %s, assume bus 0\n", 612 printk(KERN_WARNING "Can't get bus-range for %s, assume bus 0\n",
613 dev->full_name); 613 dev->full_name);
614 } 614 }
615 615
616 hose = alloc_bootmem(sizeof(struct pci_controller)); 616 hose = alloc_bootmem(sizeof(struct pci_controller));
617 if (hose == NULL) 617 if (hose == NULL)
618 return -ENOMEM; 618 return -ENOMEM;
619 pci_setup_pci_controller(hose); 619 pci_setup_pci_controller(hose);
620 620
621 hose->arch_data = dev; 621 hose->arch_data = dev;
622 hose->first_busno = bus_range ? bus_range[0] : 0; 622 hose->first_busno = bus_range ? bus_range[0] : 0;
623 hose->last_busno = bus_range ? bus_range[1] : 0xff; 623 hose->last_busno = bus_range ? bus_range[1] : 0xff;
624 624
625 of_prop = alloc_bootmem(sizeof(struct property) + 625 of_prop = alloc_bootmem(sizeof(struct property) +
626 sizeof(hose->global_number)); 626 sizeof(hose->global_number));
@@ -634,24 +634,24 @@ static int __init add_bridge(struct device_node *dev)
634 } 634 }
635 635
636 disp_name = NULL; 636 disp_name = NULL;
637 if (device_is_compatible(dev, "u3-agp")) { 637 if (device_is_compatible(dev, "u3-agp")) {
638 setup_u3_agp(hose); 638 setup_u3_agp(hose);
639 disp_name = "U3-AGP"; 639 disp_name = "U3-AGP";
640 primary = 0; 640 primary = 0;
641 } else if (device_is_compatible(dev, "u3-ht")) { 641 } else if (device_is_compatible(dev, "u3-ht")) {
642 setup_u3_ht(hose); 642 setup_u3_ht(hose);
643 disp_name = "U3-HT"; 643 disp_name = "U3-HT";
644 primary = 1; 644 primary = 1;
645 } 645 }
646 printk(KERN_INFO "Found %s PCI host bridge. Firmware bus number: %d->%d\n", 646 printk(KERN_INFO "Found %s PCI host bridge. Firmware bus number: %d->%d\n",
647 disp_name, hose->first_busno, hose->last_busno); 647 disp_name, hose->first_busno, hose->last_busno);
648 648
649 /* Interpret the "ranges" property */ 649 /* Interpret the "ranges" property */
650 /* This also maps the I/O region and sets isa_io/mem_base */ 650 /* This also maps the I/O region and sets isa_io/mem_base */
651 pmac_process_bridge_OF_ranges(hose, dev, primary); 651 pmac_process_bridge_OF_ranges(hose, dev, primary);
652 652
653 /* Fixup "bus-range" OF property */ 653 /* Fixup "bus-range" OF property */
654 fixup_bus_range(dev); 654 fixup_bus_range(dev);
655 655
656 return 0; 656 return 0;
657} 657}
diff --git a/arch/ppc64/kernel/pmac_setup.c b/arch/ppc64/kernel/pmac_setup.c
index e7f695dcd8c8..325426c7bed0 100644
--- a/arch/ppc64/kernel/pmac_setup.c
+++ b/arch/ppc64/kernel/pmac_setup.c
@@ -477,6 +477,18 @@ static int __init pmac_probe(int platform)
477 return 1; 477 return 1;
478} 478}
479 479
480static int pmac_probe_mode(struct pci_bus *bus)
481{
482 struct device_node *node = bus->sysdata;
483
484 /* We need to use normal PCI probing for the AGP bus,
485 since the device for the AGP bridge isn't in the tree. */
486 if (bus->self == NULL && device_is_compatible(node, "u3-agp"))
487 return PCI_PROBE_NORMAL;
488
489 return PCI_PROBE_DEVTREE;
490}
491
480struct machdep_calls __initdata pmac_md = { 492struct machdep_calls __initdata pmac_md = {
481#ifdef CONFIG_HOTPLUG_CPU 493#ifdef CONFIG_HOTPLUG_CPU
482 .cpu_die = generic_mach_cpu_die, 494 .cpu_die = generic_mach_cpu_die,
@@ -488,6 +500,7 @@ struct machdep_calls __initdata pmac_md = {
488 .init_IRQ = pmac_init_IRQ, 500 .init_IRQ = pmac_init_IRQ,
489 .get_irq = mpic_get_irq, 501 .get_irq = mpic_get_irq,
490 .pcibios_fixup = pmac_pcibios_fixup, 502 .pcibios_fixup = pmac_pcibios_fixup,
503 .pci_probe_mode = pmac_probe_mode,
491 .restart = pmac_restart, 504 .restart = pmac_restart,
492 .power_off = pmac_power_off, 505 .power_off = pmac_power_off,
493 .halt = pmac_halt, 506 .halt = pmac_halt,
diff --git a/arch/ppc64/kernel/process.c b/arch/ppc64/kernel/process.c
index 7a7e027653ad..887005358eb1 100644
--- a/arch/ppc64/kernel/process.c
+++ b/arch/ppc64/kernel/process.c
@@ -54,6 +54,7 @@
54#include <asm/sections.h> 54#include <asm/sections.h>
55#include <asm/tlbflush.h> 55#include <asm/tlbflush.h>
56#include <asm/time.h> 56#include <asm/time.h>
57#include <asm/plpar_wrappers.h>
57 58
58#ifndef CONFIG_SMP 59#ifndef CONFIG_SMP
59struct task_struct *last_task_used_math = NULL; 60struct task_struct *last_task_used_math = NULL;
@@ -163,7 +164,30 @@ int dump_task_altivec(struct pt_regs *regs, elf_vrregset_t *vrregs)
163 164
164#endif /* CONFIG_ALTIVEC */ 165#endif /* CONFIG_ALTIVEC */
165 166
167static void set_dabr_spr(unsigned long val)
168{
169 mtspr(SPRN_DABR, val);
170}
171
172int set_dabr(unsigned long dabr)
173{
174 int ret = 0;
175
176 if (firmware_has_feature(FW_FEATURE_XDABR)) {
177 /* We want to catch accesses from kernel and userspace */
178 unsigned long flags = H_DABRX_KERNEL|H_DABRX_USER;
179 ret = plpar_set_xdabr(dabr, flags);
180 } else if (firmware_has_feature(FW_FEATURE_DABR)) {
181 ret = plpar_set_dabr(dabr);
182 } else {
183 set_dabr_spr(dabr);
184 }
185
186 return ret;
187}
188
166DEFINE_PER_CPU(struct cpu_usage, cpu_usage_array); 189DEFINE_PER_CPU(struct cpu_usage, cpu_usage_array);
190static DEFINE_PER_CPU(unsigned long, current_dabr);
167 191
168struct task_struct *__switch_to(struct task_struct *prev, 192struct task_struct *__switch_to(struct task_struct *prev,
169 struct task_struct *new) 193 struct task_struct *new)
@@ -198,6 +222,11 @@ struct task_struct *__switch_to(struct task_struct *prev,
198 new->thread.regs->msr |= MSR_VEC; 222 new->thread.regs->msr |= MSR_VEC;
199#endif /* CONFIG_ALTIVEC */ 223#endif /* CONFIG_ALTIVEC */
200 224
225 if (unlikely(__get_cpu_var(current_dabr) != new->thread.dabr)) {
226 set_dabr(new->thread.dabr);
227 __get_cpu_var(current_dabr) = new->thread.dabr;
228 }
229
201 flush_tlb_pending(); 230 flush_tlb_pending();
202 231
203 new_thread = &new->thread; 232 new_thread = &new->thread;
@@ -334,6 +363,11 @@ void flush_thread(void)
334 last_task_used_altivec = NULL; 363 last_task_used_altivec = NULL;
335#endif /* CONFIG_ALTIVEC */ 364#endif /* CONFIG_ALTIVEC */
336#endif /* CONFIG_SMP */ 365#endif /* CONFIG_SMP */
366
367 if (current->thread.dabr) {
368 current->thread.dabr = 0;
369 set_dabr(0);
370 }
337} 371}
338 372
339void 373void
diff --git a/arch/ppc64/kernel/ptrace.c b/arch/ppc64/kernel/ptrace.c
index 2993f108d96d..85ed3188a91d 100644
--- a/arch/ppc64/kernel/ptrace.c
+++ b/arch/ppc64/kernel/ptrace.c
@@ -17,6 +17,7 @@
17 * this archive for more details. 17 * this archive for more details.
18 */ 18 */
19 19
20#include <linux/config.h>
20#include <linux/kernel.h> 21#include <linux/kernel.h>
21#include <linux/sched.h> 22#include <linux/sched.h>
22#include <linux/mm.h> 23#include <linux/mm.h>
@@ -206,6 +207,19 @@ int sys_ptrace(long request, long pid, long addr, long data)
206 break; 207 break;
207 } 208 }
208 209
210 case PTRACE_GET_DEBUGREG: {
211 ret = -EINVAL;
212 /* We only support one DABR and no IABRS at the moment */
213 if (addr > 0)
214 break;
215 ret = put_user(child->thread.dabr,
216 (unsigned long __user *)data);
217 break;
218 }
219
220 case PTRACE_SET_DEBUGREG:
221 ret = ptrace_set_debugreg(child, addr, data);
222
209 case PTRACE_DETACH: 223 case PTRACE_DETACH:
210 ret = ptrace_detach(child, data); 224 ret = ptrace_detach(child, data);
211 break; 225 break;
@@ -274,6 +288,20 @@ int sys_ptrace(long request, long pid, long addr, long data)
274 break; 288 break;
275 } 289 }
276 290
291#ifdef CONFIG_ALTIVEC
292 case PTRACE_GETVRREGS:
293 /* Get the child altivec register state. */
294 flush_altivec_to_thread(child);
295 ret = get_vrregs((unsigned long __user *)data, child);
296 break;
297
298 case PTRACE_SETVRREGS:
299 /* Set the child altivec register state. */
300 flush_altivec_to_thread(child);
301 ret = set_vrregs(child, (unsigned long __user *)data);
302 break;
303#endif
304
277 default: 305 default:
278 ret = ptrace_request(child, request, addr, data); 306 ret = ptrace_request(child, request, addr, data);
279 break; 307 break;
diff --git a/arch/ppc64/kernel/ptrace32.c b/arch/ppc64/kernel/ptrace32.c
index 16436426c7e2..fb8c22d6084a 100644
--- a/arch/ppc64/kernel/ptrace32.c
+++ b/arch/ppc64/kernel/ptrace32.c
@@ -17,6 +17,7 @@
17 * this archive for more details. 17 * this archive for more details.
18 */ 18 */
19 19
20#include <linux/config.h>
20#include <linux/kernel.h> 21#include <linux/kernel.h>
21#include <linux/sched.h> 22#include <linux/sched.h>
22#include <linux/mm.h> 23#include <linux/mm.h>
@@ -337,6 +338,19 @@ int sys32_ptrace(long request, long pid, unsigned long addr, unsigned long data)
337 break; 338 break;
338 } 339 }
339 340
341 case PTRACE_GET_DEBUGREG: {
342 ret = -EINVAL;
343 /* We only support one DABR and no IABRS at the moment */
344 if (addr > 0)
345 break;
346 ret = put_user(child->thread.dabr, (u32 __user *)data);
347 break;
348 }
349
350 case PTRACE_SET_DEBUGREG:
351 ret = ptrace_set_debugreg(child, addr, data);
352 break;
353
340 case PTRACE_DETACH: 354 case PTRACE_DETACH:
341 ret = ptrace_detach(child, data); 355 ret = ptrace_detach(child, data);
342 break; 356 break;
@@ -405,9 +419,23 @@ int sys32_ptrace(long request, long pid, unsigned long addr, unsigned long data)
405 break; 419 break;
406 } 420 }
407 421
408 case PTRACE_GETEVENTMSG: 422 case PTRACE_GETEVENTMSG:
409 ret = put_user(child->ptrace_message, (unsigned int __user *) data); 423 ret = put_user(child->ptrace_message, (unsigned int __user *) data);
410 break; 424 break;
425
426#ifdef CONFIG_ALTIVEC
427 case PTRACE_GETVRREGS:
428 /* Get the child altivec register state. */
429 flush_altivec_to_thread(child);
430 ret = get_vrregs((unsigned long __user *)data, child);
431 break;
432
433 case PTRACE_SETVRREGS:
434 /* Set the child altivec register state. */
435 flush_altivec_to_thread(child);
436 ret = set_vrregs(child, (unsigned long __user *)data);
437 break;
438#endif
411 439
412 default: 440 default:
413 ret = ptrace_request(child, request, addr, data); 441 ret = ptrace_request(child, request, addr, data);
diff --git a/arch/ppc64/kernel/ras.c b/arch/ppc64/kernel/ras.c
index 3c00f7bfc1b5..41b97dc9cc0a 100644
--- a/arch/ppc64/kernel/ras.c
+++ b/arch/ppc64/kernel/ras.c
@@ -59,8 +59,6 @@ char mce_data_buf[RTAS_ERROR_LOG_MAX]
59/* This is true if we are using the firmware NMI handler (typically LPAR) */ 59/* This is true if we are using the firmware NMI handler (typically LPAR) */
60extern int fwnmi_active; 60extern int fwnmi_active;
61 61
62extern void _exception(int signr, struct pt_regs *regs, int code, unsigned long addr);
63
64static int ras_get_sensor_state_token; 62static int ras_get_sensor_state_token;
65static int ras_check_exception_token; 63static int ras_check_exception_token;
66 64
diff --git a/arch/ppc64/kernel/setup.c b/arch/ppc64/kernel/setup.c
index bfa8791c9807..5ac48bd64891 100644
--- a/arch/ppc64/kernel/setup.c
+++ b/arch/ppc64/kernel/setup.c
@@ -1064,8 +1064,6 @@ void __init setup_arch(char **cmdline_p)
1064#define PPC64_LINUX_FUNCTION 0x0f000000 1064#define PPC64_LINUX_FUNCTION 0x0f000000
1065#define PPC64_IPL_MESSAGE 0xc0000000 1065#define PPC64_IPL_MESSAGE 0xc0000000
1066#define PPC64_TERM_MESSAGE 0xb0000000 1066#define PPC64_TERM_MESSAGE 0xb0000000
1067#define PPC64_ATTN_MESSAGE 0xa0000000
1068#define PPC64_DUMP_MESSAGE 0xd0000000
1069 1067
1070static void ppc64_do_msg(unsigned int src, const char *msg) 1068static void ppc64_do_msg(unsigned int src, const char *msg)
1071{ 1069{
@@ -1093,20 +1091,6 @@ void ppc64_terminate_msg(unsigned int src, const char *msg)
1093 printk("[terminate]%04x %s\n", src, msg); 1091 printk("[terminate]%04x %s\n", src, msg);
1094} 1092}
1095 1093
1096/* Print something that needs attention (device error, etc) */
1097void ppc64_attention_msg(unsigned int src, const char *msg)
1098{
1099 ppc64_do_msg(PPC64_LINUX_FUNCTION|PPC64_ATTN_MESSAGE|src, msg);
1100 printk("[attention]%04x %s\n", src, msg);
1101}
1102
1103/* Print a dump progress message. */
1104void ppc64_dump_msg(unsigned int src, const char *msg)
1105{
1106 ppc64_do_msg(PPC64_LINUX_FUNCTION|PPC64_DUMP_MESSAGE|src, msg);
1107 printk("[dump]%04x %s\n", src, msg);
1108}
1109
1110/* This should only be called on processor 0 during calibrate decr */ 1094/* This should only be called on processor 0 during calibrate decr */
1111void __init setup_default_decr(void) 1095void __init setup_default_decr(void)
1112{ 1096{
diff --git a/arch/ppc64/kernel/signal.c b/arch/ppc64/kernel/signal.c
index 49a79a55c32d..347112cca3c0 100644
--- a/arch/ppc64/kernel/signal.c
+++ b/arch/ppc64/kernel/signal.c
@@ -550,6 +550,15 @@ int do_signal(sigset_t *oldset, struct pt_regs *regs)
550 /* Whee! Actually deliver the signal. */ 550 /* Whee! Actually deliver the signal. */
551 if (TRAP(regs) == 0x0C00) 551 if (TRAP(regs) == 0x0C00)
552 syscall_restart(regs, &ka); 552 syscall_restart(regs, &ka);
553
554 /*
555 * Reenable the DABR before delivering the signal to
556 * user space. The DABR will have been cleared if it
557 * triggered inside the kernel.
558 */
559 if (current->thread.dabr)
560 set_dabr(current->thread.dabr);
561
553 return handle_signal(signr, &ka, &info, oldset, regs); 562 return handle_signal(signr, &ka, &info, oldset, regs);
554 } 563 }
555 564
diff --git a/arch/ppc64/kernel/signal32.c b/arch/ppc64/kernel/signal32.c
index 46f4d6cc7fc9..a8b7a5a56bb4 100644
--- a/arch/ppc64/kernel/signal32.c
+++ b/arch/ppc64/kernel/signal32.c
@@ -970,6 +970,14 @@ int do_signal32(sigset_t *oldset, struct pt_regs *regs)
970 newsp = regs->gpr[1]; 970 newsp = regs->gpr[1];
971 newsp &= ~0xfUL; 971 newsp &= ~0xfUL;
972 972
973 /*
974 * Reenable the DABR before delivering the signal to
975 * user space. The DABR will have been cleared if it
976 * triggered inside the kernel.
977 */
978 if (current->thread.dabr)
979 set_dabr(current->thread.dabr);
980
973 /* Whee! Actually deliver the signal. */ 981 /* Whee! Actually deliver the signal. */
974 if (ka.sa.sa_flags & SA_SIGINFO) 982 if (ka.sa.sa_flags & SA_SIGINFO)
975 ret = handle_rt_signal32(signr, &ka, &info, oldset, regs, newsp); 983 ret = handle_rt_signal32(signr, &ka, &info, oldset, regs, newsp);
diff --git a/arch/ppc64/kernel/xics.c b/arch/ppc64/kernel/xics.c
index d9dc6f28d050..daf93885dcfa 100644
--- a/arch/ppc64/kernel/xics.c
+++ b/arch/ppc64/kernel/xics.c
@@ -38,7 +38,7 @@ static void xics_mask_and_ack_irq(unsigned int irq);
38static void xics_end_irq(unsigned int irq); 38static void xics_end_irq(unsigned int irq);
39static void xics_set_affinity(unsigned int irq_nr, cpumask_t cpumask); 39static void xics_set_affinity(unsigned int irq_nr, cpumask_t cpumask);
40 40
41struct hw_interrupt_type xics_pic = { 41static struct hw_interrupt_type xics_pic = {
42 .typename = " XICS ", 42 .typename = " XICS ",
43 .startup = xics_startup, 43 .startup = xics_startup,
44 .enable = xics_enable_irq, 44 .enable = xics_enable_irq,
@@ -48,7 +48,7 @@ struct hw_interrupt_type xics_pic = {
48 .set_affinity = xics_set_affinity 48 .set_affinity = xics_set_affinity
49}; 49};
50 50
51struct hw_interrupt_type xics_8259_pic = { 51static struct hw_interrupt_type xics_8259_pic = {
52 .typename = " XICS/8259", 52 .typename = " XICS/8259",
53 .ack = xics_mask_and_ack_irq, 53 .ack = xics_mask_and_ack_irq,
54}; 54};
@@ -89,9 +89,8 @@ static struct xics_ipl __iomem *xics_per_cpu[NR_CPUS];
89static int xics_irq_8259_cascade = 0; 89static int xics_irq_8259_cascade = 0;
90static int xics_irq_8259_cascade_real = 0; 90static int xics_irq_8259_cascade_real = 0;
91static unsigned int default_server = 0xFF; 91static unsigned int default_server = 0xFF;
92/* also referenced in smp.c... */ 92static unsigned int default_distrib_server = 0;
93unsigned int default_distrib_server = 0; 93static unsigned int interrupt_server_size = 8;
94unsigned int interrupt_server_size = 8;
95 94
96/* 95/*
97 * XICS only has a single IPI, so encode the messages per CPU 96 * XICS only has a single IPI, so encode the messages per CPU
@@ -99,10 +98,10 @@ unsigned int interrupt_server_size = 8;
99struct xics_ipi_struct xics_ipi_message[NR_CPUS] __cacheline_aligned; 98struct xics_ipi_struct xics_ipi_message[NR_CPUS] __cacheline_aligned;
100 99
101/* RTAS service tokens */ 100/* RTAS service tokens */
102int ibm_get_xive; 101static int ibm_get_xive;
103int ibm_set_xive; 102static int ibm_set_xive;
104int ibm_int_on; 103static int ibm_int_on;
105int ibm_int_off; 104static int ibm_int_off;
106 105
107typedef struct { 106typedef struct {
108 int (*xirr_info_get)(int cpu); 107 int (*xirr_info_get)(int cpu);
@@ -284,16 +283,17 @@ static void xics_enable_irq(unsigned int virq)
284 call_status = rtas_call(ibm_set_xive, 3, 1, NULL, irq, server, 283 call_status = rtas_call(ibm_set_xive, 3, 1, NULL, irq, server,
285 DEFAULT_PRIORITY); 284 DEFAULT_PRIORITY);
286 if (call_status != 0) { 285 if (call_status != 0) {
287 printk(KERN_ERR "xics_enable_irq: irq=%d: ibm_set_xive " 286 printk(KERN_ERR "xics_enable_irq: irq=%u: ibm_set_xive "
288 "returned %x\n", irq, call_status); 287 "returned %d\n", irq, call_status);
288 printk("set_xive %x, server %x\n", ibm_set_xive, server);
289 return; 289 return;
290 } 290 }
291 291
292 /* Now unmask the interrupt (often a no-op) */ 292 /* Now unmask the interrupt (often a no-op) */
293 call_status = rtas_call(ibm_int_on, 1, 1, NULL, irq); 293 call_status = rtas_call(ibm_int_on, 1, 1, NULL, irq);
294 if (call_status != 0) { 294 if (call_status != 0) {
295 printk(KERN_ERR "xics_enable_irq: irq=%d: ibm_int_on " 295 printk(KERN_ERR "xics_enable_irq: irq=%u: ibm_int_on "
296 "returned %x\n", irq, call_status); 296 "returned %d\n", irq, call_status);
297 return; 297 return;
298 } 298 }
299} 299}
@@ -308,8 +308,8 @@ static void xics_disable_real_irq(unsigned int irq)
308 308
309 call_status = rtas_call(ibm_int_off, 1, 1, NULL, irq); 309 call_status = rtas_call(ibm_int_off, 1, 1, NULL, irq);
310 if (call_status != 0) { 310 if (call_status != 0) {
311 printk(KERN_ERR "xics_disable_real_irq: irq=%d: " 311 printk(KERN_ERR "xics_disable_real_irq: irq=%u: "
312 "ibm_int_off returned %x\n", irq, call_status); 312 "ibm_int_off returned %d\n", irq, call_status);
313 return; 313 return;
314 } 314 }
315 315
@@ -317,8 +317,8 @@ static void xics_disable_real_irq(unsigned int irq)
317 /* Have to set XIVE to 0xff to be able to remove a slot */ 317 /* Have to set XIVE to 0xff to be able to remove a slot */
318 call_status = rtas_call(ibm_set_xive, 3, 1, NULL, irq, server, 0xff); 318 call_status = rtas_call(ibm_set_xive, 3, 1, NULL, irq, server, 0xff);
319 if (call_status != 0) { 319 if (call_status != 0) {
320 printk(KERN_ERR "xics_disable_irq: irq=%d: ibm_set_xive(0xff)" 320 printk(KERN_ERR "xics_disable_irq: irq=%u: ibm_set_xive(0xff)"
321 " returned %x\n", irq, call_status); 321 " returned %d\n", irq, call_status);
322 return; 322 return;
323 } 323 }
324} 324}
@@ -380,7 +380,7 @@ int xics_get_irq(struct pt_regs *regs)
380 if (irq == NO_IRQ) 380 if (irq == NO_IRQ)
381 irq = real_irq_to_virt_slowpath(vec); 381 irq = real_irq_to_virt_slowpath(vec);
382 if (irq == NO_IRQ) { 382 if (irq == NO_IRQ) {
383 printk(KERN_ERR "Interrupt %d (real) is invalid," 383 printk(KERN_ERR "Interrupt %u (real) is invalid,"
384 " disabling it.\n", vec); 384 " disabling it.\n", vec);
385 xics_disable_real_irq(vec); 385 xics_disable_real_irq(vec);
386 } else 386 } else
@@ -622,7 +622,7 @@ static void xics_set_affinity(unsigned int virq, cpumask_t cpumask)
622 status = rtas_call(ibm_get_xive, 1, 3, xics_status, irq); 622 status = rtas_call(ibm_get_xive, 1, 3, xics_status, irq);
623 623
624 if (status) { 624 if (status) {
625 printk(KERN_ERR "xics_set_affinity: irq=%d ibm,get-xive " 625 printk(KERN_ERR "xics_set_affinity: irq=%u ibm,get-xive "
626 "returns %d\n", irq, status); 626 "returns %d\n", irq, status);
627 return; 627 return;
628 } 628 }
@@ -641,7 +641,7 @@ static void xics_set_affinity(unsigned int virq, cpumask_t cpumask)
641 irq, newmask, xics_status[1]); 641 irq, newmask, xics_status[1]);
642 642
643 if (status) { 643 if (status) {
644 printk(KERN_ERR "xics_set_affinity: irq=%d ibm,set-xive " 644 printk(KERN_ERR "xics_set_affinity: irq=%u ibm,set-xive "
645 "returns %d\n", irq, status); 645 "returns %d\n", irq, status);
646 return; 646 return;
647 } 647 }
@@ -720,7 +720,7 @@ void xics_migrate_irqs_away(void)
720 720
721 status = rtas_call(ibm_get_xive, 1, 3, xics_status, irq); 721 status = rtas_call(ibm_get_xive, 1, 3, xics_status, irq);
722 if (status) { 722 if (status) {
723 printk(KERN_ERR "migrate_irqs_away: irq=%d " 723 printk(KERN_ERR "migrate_irqs_away: irq=%u "
724 "ibm,get-xive returns %d\n", 724 "ibm,get-xive returns %d\n",
725 virq, status); 725 virq, status);
726 goto unlock; 726 goto unlock;
@@ -734,7 +734,7 @@ void xics_migrate_irqs_away(void)
734 if (xics_status[0] != get_hard_smp_processor_id(cpu)) 734 if (xics_status[0] != get_hard_smp_processor_id(cpu))
735 goto unlock; 735 goto unlock;
736 736
737 printk(KERN_WARNING "IRQ %d affinity broken off cpu %u\n", 737 printk(KERN_WARNING "IRQ %u affinity broken off cpu %u\n",
738 virq, cpu); 738 virq, cpu);
739 739
740 /* Reset affinity to all cpus */ 740 /* Reset affinity to all cpus */
diff --git a/arch/ppc64/mm/fault.c b/arch/ppc64/mm/fault.c
index 772f0714a5b7..7fbc68bbb739 100644
--- a/arch/ppc64/mm/fault.c
+++ b/arch/ppc64/mm/fault.c
@@ -77,6 +77,28 @@ static int store_updates_sp(struct pt_regs *regs)
77 return 0; 77 return 0;
78} 78}
79 79
80static void do_dabr(struct pt_regs *regs, unsigned long error_code)
81{
82 siginfo_t info;
83
84 if (notify_die(DIE_DABR_MATCH, "dabr_match", regs, error_code,
85 11, SIGSEGV) == NOTIFY_STOP)
86 return;
87
88 if (debugger_dabr_match(regs))
89 return;
90
91 /* Clear the DABR */
92 set_dabr(0);
93
94 /* Deliver the signal to userspace */
95 info.si_signo = SIGTRAP;
96 info.si_errno = 0;
97 info.si_code = TRAP_HWBKPT;
98 info.si_addr = (void __user *)regs->nip;
99 force_sig_info(SIGTRAP, &info, current);
100}
101
80/* 102/*
81 * The error_code parameter is 103 * The error_code parameter is
82 * - DSISR for a non-SLB data access fault, 104 * - DSISR for a non-SLB data access fault,
@@ -111,12 +133,9 @@ int __kprobes do_page_fault(struct pt_regs *regs, unsigned long address,
111 if (!user_mode(regs) && (address >= TASK_SIZE)) 133 if (!user_mode(regs) && (address >= TASK_SIZE))
112 return SIGSEGV; 134 return SIGSEGV;
113 135
114 if (error_code & DSISR_DABRMATCH) { 136 if (error_code & DSISR_DABRMATCH) {
115 if (notify_die(DIE_DABR_MATCH, "dabr_match", regs, error_code, 137 do_dabr(regs, error_code);
116 11, SIGSEGV) == NOTIFY_STOP) 138 return 0;
117 return 0;
118 if (debugger_dabr_match(regs))
119 return 0;
120 } 139 }
121 140
122 if (in_atomic() || mm == NULL) { 141 if (in_atomic() || mm == NULL) {
diff --git a/arch/ppc64/xmon/privinst.h b/arch/ppc64/xmon/privinst.h
index 183c3e400258..02eb40dac0b3 100644
--- a/arch/ppc64/xmon/privinst.h
+++ b/arch/ppc64/xmon/privinst.h
@@ -46,7 +46,6 @@ GSETSPR(287, pvr)
46GSETSPR(1008, hid0) 46GSETSPR(1008, hid0)
47GSETSPR(1009, hid1) 47GSETSPR(1009, hid1)
48GSETSPR(1010, iabr) 48GSETSPR(1010, iabr)
49GSETSPR(1013, dabr)
50GSETSPR(1023, pir) 49GSETSPR(1023, pir)
51 50
52static inline void store_inst(void *p) 51static inline void store_inst(void *p)
diff --git a/arch/ppc64/xmon/xmon.c b/arch/ppc64/xmon/xmon.c
index 45908b10acd3..74e63a886a69 100644
--- a/arch/ppc64/xmon/xmon.c
+++ b/arch/ppc64/xmon/xmon.c
@@ -586,6 +586,8 @@ int xmon_dabr_match(struct pt_regs *regs)
586{ 586{
587 if ((regs->msr & (MSR_IR|MSR_PR|MSR_SF)) != (MSR_IR|MSR_SF)) 587 if ((regs->msr & (MSR_IR|MSR_PR|MSR_SF)) != (MSR_IR|MSR_SF))
588 return 0; 588 return 0;
589 if (dabr.enabled == 0)
590 return 0;
589 xmon_core(regs, 0); 591 xmon_core(regs, 0);
590 return 1; 592 return 1;
591} 593}
@@ -628,20 +630,6 @@ int xmon_fault_handler(struct pt_regs *regs)
628 return 0; 630 return 0;
629} 631}
630 632
631/* On systems with a hypervisor, we can't set the DABR
632 (data address breakpoint register) directly. */
633static void set_controlled_dabr(unsigned long val)
634{
635#ifdef CONFIG_PPC_PSERIES
636 if (systemcfg->platform == PLATFORM_PSERIES_LPAR) {
637 int rc = plpar_hcall_norets(H_SET_DABR, val);
638 if (rc != H_Success)
639 xmon_printf("Warning: setting DABR failed (%d)\n", rc);
640 } else
641#endif
642 set_dabr(val);
643}
644
645static struct bpt *at_breakpoint(unsigned long pc) 633static struct bpt *at_breakpoint(unsigned long pc)
646{ 634{
647 int i; 635 int i;
@@ -728,7 +716,7 @@ static void insert_bpts(void)
728static void insert_cpu_bpts(void) 716static void insert_cpu_bpts(void)
729{ 717{
730 if (dabr.enabled) 718 if (dabr.enabled)
731 set_controlled_dabr(dabr.address | (dabr.enabled & 7)); 719 set_dabr(dabr.address | (dabr.enabled & 7));
732 if (iabr && cpu_has_feature(CPU_FTR_IABR)) 720 if (iabr && cpu_has_feature(CPU_FTR_IABR))
733 set_iabr(iabr->address 721 set_iabr(iabr->address
734 | (iabr->enabled & (BP_IABR|BP_IABR_TE))); 722 | (iabr->enabled & (BP_IABR|BP_IABR_TE)));
@@ -756,7 +744,7 @@ static void remove_bpts(void)
756 744
757static void remove_cpu_bpts(void) 745static void remove_cpu_bpts(void)
758{ 746{
759 set_controlled_dabr(0); 747 set_dabr(0);
760 if (cpu_has_feature(CPU_FTR_IABR)) 748 if (cpu_has_feature(CPU_FTR_IABR))
761 set_iabr(0); 749 set_iabr(0);
762} 750}
diff --git a/include/asm-powerpc/siginfo.h b/include/asm-powerpc/siginfo.h
index 538ea8ef509b..12f1bce037be 100644
--- a/include/asm-powerpc/siginfo.h
+++ b/include/asm-powerpc/siginfo.h
@@ -15,4 +15,12 @@
15 15
16#include <asm-generic/siginfo.h> 16#include <asm-generic/siginfo.h>
17 17
18/*
19 * SIGTRAP si_codes
20 */
21#define TRAP_BRANCH (__SI_FAULT|3) /* process taken branch trap */
22#define TRAP_HWBKPT (__SI_FAULT|4) /* hardware breakpoint or watchpoint */
23#undef NSIGTRAP
24#define NSIGTRAP 4
25
18#endif /* _ASM_POWERPC_SIGINFO_H */ 26#endif /* _ASM_POWERPC_SIGINFO_H */
diff --git a/include/asm-ppc/ptrace.h b/include/asm-ppc/ptrace.h
index 9d4e4ea530c3..7043c164b537 100644
--- a/include/asm-ppc/ptrace.h
+++ b/include/asm-ppc/ptrace.h
@@ -142,4 +142,11 @@ do { \
142#define PTRACE_GETEVRREGS 20 142#define PTRACE_GETEVRREGS 20
143#define PTRACE_SETEVRREGS 21 143#define PTRACE_SETEVRREGS 21
144 144
145/*
146 * Get or set a debug register. The first 16 are DABR registers and the
147 * second 16 are IABR registers.
148 */
149#define PTRACE_GET_DEBUGREG 25
150#define PTRACE_SET_DEBUGREG 26
151
145#endif 152#endif
diff --git a/include/asm-ppc64/hvcall.h b/include/asm-ppc64/hvcall.h
index 4f668a4baff0..ab7c3cf24888 100644
--- a/include/asm-ppc64/hvcall.h
+++ b/include/asm-ppc64/hvcall.h
@@ -56,6 +56,11 @@
56#define H_PP1 (1UL<<(63-62)) 56#define H_PP1 (1UL<<(63-62))
57#define H_PP2 (1UL<<(63-63)) 57#define H_PP2 (1UL<<(63-63))
58 58
59/* DABRX flags */
60#define H_DABRX_HYPERVISOR (1UL<<(63-61))
61#define H_DABRX_KERNEL (1UL<<(63-62))
62#define H_DABRX_USER (1UL<<(63-63))
63
59/* pSeries hypervisor opcodes */ 64/* pSeries hypervisor opcodes */
60#define H_REMOVE 0x04 65#define H_REMOVE 0x04
61#define H_ENTER 0x08 66#define H_ENTER 0x08
@@ -101,6 +106,7 @@
101#define H_VIO_SIGNAL 0x104 106#define H_VIO_SIGNAL 0x104
102#define H_SEND_CRQ 0x108 107#define H_SEND_CRQ 0x108
103#define H_COPY_RDMA 0x110 108#define H_COPY_RDMA 0x110
109#define H_SET_XDABR 0x134
104#define H_STUFF_TCE 0x138 110#define H_STUFF_TCE 0x138
105#define H_PUT_TCE_INDIRECT 0x13C 111#define H_PUT_TCE_INDIRECT 0x13C
106#define H_VTERM_PARTNER_INFO 0x150 112#define H_VTERM_PARTNER_INFO 0x150
diff --git a/include/asm-ppc64/machdep.h b/include/asm-ppc64/machdep.h
index 9a1ef4427ed2..8027160ec96d 100644
--- a/include/asm-ppc64/machdep.h
+++ b/include/asm-ppc64/machdep.h
@@ -88,6 +88,7 @@ struct machdep_calls {
88 88
89 /* PCI stuff */ 89 /* PCI stuff */
90 void (*pcibios_fixup)(void); 90 void (*pcibios_fixup)(void);
91 int (*pci_probe_mode)(struct pci_bus *);
91 92
92 void (*restart)(char *cmd); 93 void (*restart)(char *cmd);
93 void (*power_off)(void); 94 void (*power_off)(void);
@@ -173,10 +174,6 @@ extern sys_ctrler_t sys_ctrler;
173void ppc64_boot_msg(unsigned int src, const char *msg); 174void ppc64_boot_msg(unsigned int src, const char *msg);
174/* Print a termination message (print only -- does not stop the kernel) */ 175/* Print a termination message (print only -- does not stop the kernel) */
175void ppc64_terminate_msg(unsigned int src, const char *msg); 176void ppc64_terminate_msg(unsigned int src, const char *msg);
176/* Print something that needs attention (device error, etc) */
177void ppc64_attention_msg(unsigned int src, const char *msg);
178/* Print a dump progress message. */
179void ppc64_dump_msg(unsigned int src, const char *msg);
180 177
181static inline void log_error(char *buf, unsigned int err_type, int fatal) 178static inline void log_error(char *buf, unsigned int err_type, int fatal)
182{ 179{
diff --git a/include/asm-ppc64/pci-bridge.h b/include/asm-ppc64/pci-bridge.h
index 6b4a5b1f695e..d8991389ab39 100644
--- a/include/asm-ppc64/pci-bridge.h
+++ b/include/asm-ppc64/pci-bridge.h
@@ -119,5 +119,10 @@ static inline struct pci_controller *pci_bus_to_host(struct pci_bus *bus)
119 return PCI_DN(busdn)->phb; 119 return PCI_DN(busdn)->phb;
120} 120}
121 121
122/* Return values for ppc_md.pci_probe_mode function */
123#define PCI_PROBE_NONE -1 /* Don't look at this bus at all */
124#define PCI_PROBE_NORMAL 0 /* Do normal PCI probing */
125#define PCI_PROBE_DEVTREE 1 /* Instantiate from device tree */
126
122#endif 127#endif
123#endif /* __KERNEL__ */ 128#endif /* __KERNEL__ */
diff --git a/include/asm-ppc64/plpar_wrappers.h b/include/asm-ppc64/plpar_wrappers.h
index f4a5fb7d67c7..72dd2449ee76 100644
--- a/include/asm-ppc64/plpar_wrappers.h
+++ b/include/asm-ppc64/plpar_wrappers.h
@@ -107,5 +107,14 @@ static inline long plpar_put_term_char(unsigned long termno,
107 lbuf[1]); 107 lbuf[1]);
108} 108}
109 109
110static inline long plpar_set_xdabr(unsigned long address, unsigned long flags)
111{
112 return plpar_hcall_norets(H_SET_XDABR, address, flags);
113}
114
115static inline long plpar_set_dabr(unsigned long val)
116{
117 return plpar_hcall_norets(H_SET_DABR, val);
118}
110 119
111#endif /* _PPC64_PLPAR_WRAPPERS_H */ 120#endif /* _PPC64_PLPAR_WRAPPERS_H */
diff --git a/include/asm-ppc64/processor.h b/include/asm-ppc64/processor.h
index 8bd7aa959385..4146189006e3 100644
--- a/include/asm-ppc64/processor.h
+++ b/include/asm-ppc64/processor.h
@@ -433,6 +433,7 @@ struct thread_struct {
433 unsigned long start_tb; /* Start purr when proc switched in */ 433 unsigned long start_tb; /* Start purr when proc switched in */
434 unsigned long accum_tb; /* Total accumilated purr for process */ 434 unsigned long accum_tb; /* Total accumilated purr for process */
435 unsigned long vdso_base; /* base of the vDSO library */ 435 unsigned long vdso_base; /* base of the vDSO library */
436 unsigned long dabr; /* Data address breakpoint register */
436#ifdef CONFIG_ALTIVEC 437#ifdef CONFIG_ALTIVEC
437 /* Complete AltiVec register set */ 438 /* Complete AltiVec register set */
438 vector128 vr[32] __attribute((aligned(16))); 439 vector128 vr[32] __attribute((aligned(16)));
diff --git a/include/asm-ppc64/ptrace-common.h b/include/asm-ppc64/ptrace-common.h
index af03547f9c7e..b1babb729673 100644
--- a/include/asm-ppc64/ptrace-common.h
+++ b/include/asm-ppc64/ptrace-common.h
@@ -11,6 +11,10 @@
11 11
12#ifndef _PPC64_PTRACE_COMMON_H 12#ifndef _PPC64_PTRACE_COMMON_H
13#define _PPC64_PTRACE_COMMON_H 13#define _PPC64_PTRACE_COMMON_H
14
15#include <linux/config.h>
16#include <asm/system.h>
17
14/* 18/*
15 * Set of msr bits that gdb can change on behalf of a process. 19 * Set of msr bits that gdb can change on behalf of a process.
16 */ 20 */
@@ -69,4 +73,92 @@ static inline void clear_single_step(struct task_struct *task)
69 clear_ti_thread_flag(task->thread_info, TIF_SINGLESTEP); 73 clear_ti_thread_flag(task->thread_info, TIF_SINGLESTEP);
70} 74}
71 75
76#ifdef CONFIG_ALTIVEC
77/*
78 * Get/set all the altivec registers vr0..vr31, vscr, vrsave, in one go.
79 * The transfer totals 34 quadword. Quadwords 0-31 contain the
80 * corresponding vector registers. Quadword 32 contains the vscr as the
81 * last word (offset 12) within that quadword. Quadword 33 contains the
82 * vrsave as the first word (offset 0) within the quadword.
83 *
84 * This definition of the VMX state is compatible with the current PPC32
85 * ptrace interface. This allows signal handling and ptrace to use the
86 * same structures. This also simplifies the implementation of a bi-arch
87 * (combined (32- and 64-bit) gdb.
88 */
89
90/*
91 * Get contents of AltiVec register state in task TASK
92 */
93static inline int get_vrregs(unsigned long __user *data,
94 struct task_struct *task)
95{
96 unsigned long regsize;
97
98 /* copy AltiVec registers VR[0] .. VR[31] */
99 regsize = 32 * sizeof(vector128);
100 if (copy_to_user(data, task->thread.vr, regsize))
101 return -EFAULT;
102 data += (regsize / sizeof(unsigned long));
103
104 /* copy VSCR */
105 regsize = 1 * sizeof(vector128);
106 if (copy_to_user(data, &task->thread.vscr, regsize))
107 return -EFAULT;
108 data += (regsize / sizeof(unsigned long));
109
110 /* copy VRSAVE */
111 if (put_user(task->thread.vrsave, (u32 __user *)data))
112 return -EFAULT;
113
114 return 0;
115}
116
117/*
118 * Write contents of AltiVec register state into task TASK.
119 */
120static inline int set_vrregs(struct task_struct *task,
121 unsigned long __user *data)
122{
123 unsigned long regsize;
124
125 /* copy AltiVec registers VR[0] .. VR[31] */
126 regsize = 32 * sizeof(vector128);
127 if (copy_from_user(task->thread.vr, data, regsize))
128 return -EFAULT;
129 data += (regsize / sizeof(unsigned long));
130
131 /* copy VSCR */
132 regsize = 1 * sizeof(vector128);
133 if (copy_from_user(&task->thread.vscr, data, regsize))
134 return -EFAULT;
135 data += (regsize / sizeof(unsigned long));
136
137 /* copy VRSAVE */
138 if (get_user(task->thread.vrsave, (u32 __user *)data))
139 return -EFAULT;
140
141 return 0;
142}
143#endif
144
145static inline int ptrace_set_debugreg(struct task_struct *task,
146 unsigned long addr, unsigned long data)
147{
148 /* We only support one DABR and no IABRS at the moment */
149 if (addr > 0)
150 return -EINVAL;
151
152 /* The bottom 3 bits are flags */
153 if ((data & ~0x7UL) >= TASK_SIZE)
154 return -EIO;
155
156 /* Ensure translation is on */
157 if (data && !(data & DABR_TRANSLATION))
158 return -EIO;
159
160 task->thread.dabr = data;
161 return 0;
162}
163
72#endif /* _PPC64_PTRACE_COMMON_H */ 164#endif /* _PPC64_PTRACE_COMMON_H */
diff --git a/include/asm-ppc64/ptrace.h b/include/asm-ppc64/ptrace.h
index c96aad28fc08..3a55377f1fd3 100644
--- a/include/asm-ppc64/ptrace.h
+++ b/include/asm-ppc64/ptrace.h
@@ -25,56 +25,49 @@
25 */ 25 */
26 26
27#ifndef __ASSEMBLY__ 27#ifndef __ASSEMBLY__
28#define PPC_REG unsigned long 28
29struct pt_regs { 29struct pt_regs {
30 PPC_REG gpr[32]; 30 unsigned long gpr[32];
31 PPC_REG nip; 31 unsigned long nip;
32 PPC_REG msr; 32 unsigned long msr;
33 PPC_REG orig_gpr3; /* Used for restarting system calls */ 33 unsigned long orig_gpr3; /* Used for restarting system calls */
34 PPC_REG ctr; 34 unsigned long ctr;
35 PPC_REG link; 35 unsigned long link;
36 PPC_REG xer; 36 unsigned long xer;
37 PPC_REG ccr; 37 unsigned long ccr;
38 PPC_REG softe; /* Soft enabled/disabled */ 38 unsigned long softe; /* Soft enabled/disabled */
39 PPC_REG trap; /* Reason for being here */ 39 unsigned long trap; /* Reason for being here */
40 PPC_REG dar; /* Fault registers */ 40 unsigned long dar; /* Fault registers */
41 PPC_REG dsisr; 41 unsigned long dsisr;
42 PPC_REG result; /* Result of a system call */ 42 unsigned long result; /* Result of a system call */
43}; 43};
44 44
45#define PPC_REG_32 unsigned int
46struct pt_regs32 { 45struct pt_regs32 {
47 PPC_REG_32 gpr[32]; 46 unsigned int gpr[32];
48 PPC_REG_32 nip; 47 unsigned int nip;
49 PPC_REG_32 msr; 48 unsigned int msr;
50 PPC_REG_32 orig_gpr3; /* Used for restarting system calls */ 49 unsigned int orig_gpr3; /* Used for restarting system calls */
51 PPC_REG_32 ctr; 50 unsigned int ctr;
52 PPC_REG_32 link; 51 unsigned int link;
53 PPC_REG_32 xer; 52 unsigned int xer;
54 PPC_REG_32 ccr; 53 unsigned int ccr;
55 PPC_REG_32 mq; /* 601 only (not used at present) */ 54 unsigned int mq; /* 601 only (not used at present) */
56 /* Used on APUS to hold IPL value. */ 55 unsigned int trap; /* Reason for being here */
57 PPC_REG_32 trap; /* Reason for being here */ 56 unsigned int dar; /* Fault registers */
58 PPC_REG_32 dar; /* Fault registers */ 57 unsigned int dsisr;
59 PPC_REG_32 dsisr; 58 unsigned int result; /* Result of a system call */
60 PPC_REG_32 result; /* Result of a system call */
61}; 59};
62 60
61#ifdef __KERNEL__
62
63#define instruction_pointer(regs) ((regs)->nip) 63#define instruction_pointer(regs) ((regs)->nip)
64
64#ifdef CONFIG_SMP 65#ifdef CONFIG_SMP
65extern unsigned long profile_pc(struct pt_regs *regs); 66extern unsigned long profile_pc(struct pt_regs *regs);
66#else 67#else
67#define profile_pc(regs) instruction_pointer(regs) 68#define profile_pc(regs) instruction_pointer(regs)
68#endif 69#endif
69 70
70#endif /* __ASSEMBLY__ */
71
72#define STACK_FRAME_OVERHEAD 112 /* size of minimum stack frame */
73
74/* Size of dummy stack frame allocated when calling signal handler. */
75#define __SIGNAL_FRAMESIZE 128
76#define __SIGNAL_FRAMESIZE32 64
77
78#define user_mode(regs) ((((regs)->msr) >> MSR_PR_LG) & 0x1) 71#define user_mode(regs) ((((regs)->msr) >> MSR_PR_LG) & 0x1)
79 72
80#define force_successful_syscall_return() \ 73#define force_successful_syscall_return() \
@@ -89,6 +82,16 @@ extern unsigned long profile_pc(struct pt_regs *regs);
89#define TRAP(regs) ((regs)->trap & ~0xF) 82#define TRAP(regs) ((regs)->trap & ~0xF)
90#define CHECK_FULL_REGS(regs) BUG_ON(regs->trap & 1) 83#define CHECK_FULL_REGS(regs) BUG_ON(regs->trap & 1)
91 84
85#endif /* __KERNEL__ */
86
87#endif /* __ASSEMBLY__ */
88
89#define STACK_FRAME_OVERHEAD 112 /* size of minimum stack frame */
90
91/* Size of dummy stack frame allocated when calling signal handler. */
92#define __SIGNAL_FRAMESIZE 128
93#define __SIGNAL_FRAMESIZE32 64
94
92/* 95/*
93 * Offsets used by 'ptrace' system call interface. 96 * Offsets used by 'ptrace' system call interface.
94 */ 97 */
@@ -135,17 +138,21 @@ extern unsigned long profile_pc(struct pt_regs *regs);
135#define PT_XER 37 138#define PT_XER 37
136#define PT_CCR 38 139#define PT_CCR 38
137#define PT_SOFTE 39 140#define PT_SOFTE 39
141#define PT_TRAP 40
142#define PT_DAR 41
143#define PT_DSISR 42
138#define PT_RESULT 43 144#define PT_RESULT 43
139 145
140#define PT_FPR0 48 146#define PT_FPR0 48
141 147
142/* Kernel and userspace will both use this PT_FPSCR value. 32-bit apps will have 148/*
143 * visibility to the asm-ppc/ptrace.h header instead of this one. 149 * Kernel and userspace will both use this PT_FPSCR value. 32-bit apps will
150 * have visibility to the asm-ppc/ptrace.h header instead of this one.
144 */ 151 */
145#define PT_FPSCR (PT_FPR0 + 32) /* each FP reg occupies 1 slot in 64-bit space */ 152#define PT_FPSCR (PT_FPR0 + 32) /* each FP reg occupies 1 slot in 64-bit space */
146 153
147#ifdef __KERNEL__ 154#ifdef __KERNEL__
148#define PT_FPSCR32 (PT_FPR0 + 2*32 + 1) /* each FP reg occupies 2 32-bit userspace slots */ 155#define PT_FPSCR32 (PT_FPR0 + 2*32 + 1) /* each FP reg occupies 2 32-bit userspace slots */
149#endif 156#endif
150 157
151#define PT_VR0 82 /* each Vector reg occupies 2 slots in 64-bit */ 158#define PT_VR0 82 /* each Vector reg occupies 2 slots in 64-bit */
@@ -173,17 +180,34 @@ extern unsigned long profile_pc(struct pt_regs *regs);
173#define PTRACE_GETVRREGS 18 180#define PTRACE_GETVRREGS 18
174#define PTRACE_SETVRREGS 19 181#define PTRACE_SETVRREGS 19
175 182
176/* Additional PTRACE requests implemented on PowerPC. */ 183/*
177#define PPC_PTRACE_GETREGS 0x99 /* Get GPRs 0 - 31 */ 184 * While we dont have 64bit book E processors, we need to reserve the
178#define PPC_PTRACE_SETREGS 0x98 /* Set GPRs 0 - 31 */ 185 * relevant ptrace calls for 32bit compatibility.
179#define PPC_PTRACE_GETFPREGS 0x97 /* Get FPRs 0 - 31 */ 186 */
180#define PPC_PTRACE_SETFPREGS 0x96 /* Set FPRs 0 - 31 */ 187#if 0
181#define PPC_PTRACE_PEEKTEXT_3264 0x95 /* Read word at location ADDR on a 64-bit process from a 32-bit process. */ 188#define PTRACE_GETEVRREGS 20
182#define PPC_PTRACE_PEEKDATA_3264 0x94 /* Read word at location ADDR on a 64-bit process from a 32-bit process. */ 189#define PTRACE_SETEVRREGS 21
183#define PPC_PTRACE_POKETEXT_3264 0x93 /* Write word at location ADDR on a 64-bit process from a 32-bit process. */ 190#endif
184#define PPC_PTRACE_POKEDATA_3264 0x92 /* Write word at location ADDR on a 64-bit process from a 32-bit process. */
185#define PPC_PTRACE_PEEKUSR_3264 0x91 /* Read a register (specified by ADDR) out of the "user area" on a 64-bit process from a 32-bit process. */
186#define PPC_PTRACE_POKEUSR_3264 0x90 /* Write DATA into location ADDR within the "user area" on a 64-bit process from a 32-bit process. */
187 191
192/*
193 * Get or set a debug register. The first 16 are DABR registers and the
194 * second 16 are IABR registers.
195 */
196#define PTRACE_GET_DEBUGREG 25
197#define PTRACE_SET_DEBUGREG 26
198
199/* Additional PTRACE requests implemented on PowerPC. */
200#define PPC_PTRACE_GETREGS 0x99 /* Get GPRs 0 - 31 */
201#define PPC_PTRACE_SETREGS 0x98 /* Set GPRs 0 - 31 */
202#define PPC_PTRACE_GETFPREGS 0x97 /* Get FPRs 0 - 31 */
203#define PPC_PTRACE_SETFPREGS 0x96 /* Set FPRs 0 - 31 */
204
205/* Calls to trace a 64bit program from a 32bit program */
206#define PPC_PTRACE_PEEKTEXT_3264 0x95
207#define PPC_PTRACE_PEEKDATA_3264 0x94
208#define PPC_PTRACE_POKETEXT_3264 0x93
209#define PPC_PTRACE_POKEDATA_3264 0x92
210#define PPC_PTRACE_PEEKUSR_3264 0x91
211#define PPC_PTRACE_POKEUSR_3264 0x90
188 212
189#endif /* _PPC64_PTRACE_H */ 213#endif /* _PPC64_PTRACE_H */
diff --git a/include/asm-ppc64/system.h b/include/asm-ppc64/system.h
index c0396428cc3c..375015c62f20 100644
--- a/include/asm-ppc64/system.h
+++ b/include/asm-ppc64/system.h
@@ -101,6 +101,9 @@ static inline int debugger_dabr_match(struct pt_regs *regs) { return 0; }
101static inline int debugger_fault_handler(struct pt_regs *regs) { return 0; } 101static inline int debugger_fault_handler(struct pt_regs *regs) { return 0; }
102#endif 102#endif
103 103
104extern int set_dabr(unsigned long dabr);
105extern void _exception(int signr, struct pt_regs *regs, int code,
106 unsigned long addr);
104extern int fix_alignment(struct pt_regs *regs); 107extern int fix_alignment(struct pt_regs *regs);
105extern void bad_page_fault(struct pt_regs *regs, unsigned long address, 108extern void bad_page_fault(struct pt_regs *regs, unsigned long address,
106 int sig); 109 int sig);