lkcd
[Top] [All Lists]

Re: Volunteer to work with Alpha port of lkcd

To: Brian Hall <brianw.hall@xxxxxxxxxx>
Subject: Re: Volunteer to work with Alpha port of lkcd
From: Matt Robinson <yakker@xxxxxxxxxxxxxxxxxxxx>
Date: Wed, 1 Dec 1999 10:45:21 -0800 (PST)
Cc: lkcd@xxxxxxxxxxx
In-reply-to: <XFMail.19991201112048.brianw.hall@xxxxxxxxxx>
Reply-to: Matt Robinson <yakker@xxxxxxxxxxxxxxxxxxxx>
Sender: owner-lkcd@xxxxxxxxxxx
On Wed, 1 Dec 1999, Brian Hall wrote:
] I would like to work on and/or help with the port of the lkcd patch
] to the Alpha platform. I have access to several different models with
] an Alpha processor. Currently I have two 1200s and a ES40 running
] RedHat 6.0 Alpha, with various versions of the 2.2 kernel. All have
] their swap on SCSI drives and are available for lkcd testing.

Awesome, we're willing to help where we can.

] Advice on how to proceed would be helpful. Looks like some functions
] need to be made safe for 64 bits first, then new Alpha-specific
] functions need to be stubbed out in new files in the Alpha arch tree.
] I'm a little worried about the snippet of i386 ASM code to save the
] CPU registers. Hopefully I can use a PALcode system call to do that
] (and similar things) on the Alpha.

The first thing to do is to take the kernel code in
arch/i386/kernel/vmdump.c and copy it to arch/alpha/kernel, modify
the makefile, and then modify the calls for saving the pt_regs.

The code for saving the registers is mostly correct, except for:

        if (regs) {
                memcpy((void *)&(dump_header.dh_regs), (const void *)regs,
                        sizeof(struct pt_regs));
>               if (!user_mode(regs)) {
>                       dump_header.dh_regs.esp = (unsigned long) (regs + 1);
>               }
        }

Those lines aren't necessarily needed -- they are I386 specific.  We
have to adjust the esp based on the processor mode.

Also, the code for:

        /* save the dump specific esp/eip */
        __asm__ __volatile__("
                pushl %%eax\n
                movl  %%esp, %%eax\n
                movl  %%eax, %0\n
                popl  %%eax\n"
                : "=g" (dump_header.dh_esp)
        );
        __asm__ __volatile__("pushl  %eax\n");
        __dump_save_panic_regs();
        __asm__ __volatile__("popl   %eax\n");

All of this is set up just to save the stack pointer and program
counter for this box, as the pt_regs on I386 boxes don't necessarily
point to the right location.  We want to be able to walk back from
the exception where that is possible.

In looking at the Alpha stuff, I think you can start by saving the PC
and RA values (not sure which $XX they represent), and also put a hook
into die_if_kernel() in traps.c.

I'd also suggest modifying a system call to test the panic() routine
out.  Once you get that going, see if the memory is actually being
written out to the swap device as expected.  If you want, you can
change '/sbin/vmdump save' to run a special application to print out
the dump header:

#include <linux/types.h>
#include <linux/time.h>
#define CONFIG_VMDUMP
#include <linux/vmdump.h>
#include <stdio.h>

dump_header_t dump_header;

int
main(int argc, char **argv)
{
        FILE *fp;

        if (argc != 2) {
                fprintf(stderr, "Usage: %s <device>\n", argv[0]);
                return (1);
        }

        if ((fp = fopen(argv[1], "r")) == (FILE *)NULL) {
                perror("fopen");
                return (1);
        }

        fseek(fp, 4096, SEEK_SET);

        if (fread((char *)&dump_header, sizeof(dump_header_t), 1, fp) < 0) {
                perror("fread");
                return (1);
        }

        fclose(fp);

        printf("Dump Header (version %d):\n", dump_header.dh_version);
        printf("Magic number: 0x%llx\n", dump_header.dh_magic_number);
        printf("PAGE_SIZE = %d\n", dump_header.dh_page_size);
        printf("Dump header size: %d\n", dump_header.dh_header_size);
        printf("Physical memory:\n");
        printf("\tStart: 0x%x\n", dump_header.dh_memory_start);
        printf("\t  End: 0x%x\n", dump_header.dh_memory_end);
        printf("\t Size: %d\n", dump_header.dh_memory_size);
        printf("Number of pages in dump: %d\n", dump_header.dh_num_pages);
        printf("Time of dump: %s\n", ctime(&(dump_header.dh_time.tv_sec)));

        return (0);
}

If you run this against /dev/vmdump, it should print out the dump
header (it is always after the swap header, at PAGE_SIZE, or 4096 bytes,
on our system).

Let me know if this gets you started and if we can offer any other advice.
Thanks!

--Matt


] Anyone on this list familiar with the Alpha platform, from the point
] of view of the Linux kernel ? (I know, but I thought I'd ask!)
] 
] --
] Brian Hall <brianw.hall@xxxxxxxxxx>
] Linux Consultant


<Prev in Thread] Current Thread [Next in Thread>