From owner-p4-projects@FreeBSD.ORG Sun Nov 16 08:43:30 2003 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id EF51516A4D0; Sun, 16 Nov 2003 08:43:29 -0800 (PST) Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id C8A8316A4CE for ; Sun, 16 Nov 2003 08:43:29 -0800 (PST) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id E11A243FAF for ; Sun, 16 Nov 2003 08:43:28 -0800 (PST) (envelope-from bb+lists.freebsd.perforce@cyrus.watson.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.12.9/8.12.9) with ESMTP id hAGGhSXJ091862 for ; Sun, 16 Nov 2003 08:43:28 -0800 (PST) (envelope-from bb+lists.freebsd.perforce@cyrus.watson.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.12.9/8.12.9/Submit) id hAGGhSes091859 for perforce@freebsd.org; Sun, 16 Nov 2003 08:43:28 -0800 (PST) (envelope-from bb+lists.freebsd.perforce@cyrus.watson.org) Date: Sun, 16 Nov 2003 08:43:28 -0800 (PST) Message-Id: <200311161643.hAGGhSes091859@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to bb+lists.freebsd.perforce@cyrus.watson.org using -f From: Robert Watson To: Perforce Change Reviews Subject: PERFORCE change 42551 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 16 Nov 2003 16:43:30 -0000 http://perforce.freebsd.org/chv.cgi?CH=42551 Change 42551 by rwatson@rwatson_tislabs on 2003/11/16 08:42:49 Implement mac_copy_{mbuf,pipe,vnode}_label() for mac_stub.c and mac_test.c. Affected files ... .. //depot/projects/trustedbsd/mac/sys/security/mac_stub/mac_stub.c#13 edit .. //depot/projects/trustedbsd/mac/sys/security/mac_test/mac_test.c#122 edit Differences ... ==== //depot/projects/trustedbsd/mac/sys/security/mac_stub/mac_stub.c#13 (text+ko) ==== @@ -134,6 +134,12 @@ } +static void +stub_copy_label(struct label *src, struct label *dest) +{ + +} + static int stub_externalize_label(struct label *label, char *element_name, struct sbuf *sb, int *claimed) @@ -1320,6 +1326,9 @@ .mpo_destroy_socket_label = stub_destroy_label, .mpo_destroy_socket_peer_label = stub_destroy_label, .mpo_destroy_vnode_label = stub_destroy_label, + .mpo_copy_mbuf_label = stub_copy_label, + .mpo_copy_pipe_label = stub_copy_label, + .mpo_copy_vnode_label = stub_copy_label, .mpo_externalize_cred_label = stub_externalize_label, .mpo_externalize_ifnet_label = stub_externalize_label, .mpo_externalize_pipe_label = stub_externalize_label, ==== //depot/projects/trustedbsd/mac/sys/security/mac_test/mac_test.c#122 (text+ko) ==== @@ -747,6 +747,30 @@ } } +static void +mac_test_copy_mbuf_label(struct label *src, struct label *dest) +{ + + ASSERT_MBUF_LABEL(src); + ASSERT_MBUF_LABEL(dest); +} + +static void +mac_test_copy_pipe_label(struct label *src, struct label *dest) +{ + + ASSERT_PIPE_LABEL(src); + ASSERT_PIPE_LABEL(dest); +} + +static void +mac_test_copy_vnode_label(struct label *src, struct label *dest) +{ + + ASSERT_VNODE_LABEL(src); + ASSERT_VNODE_LABEL(dest); +} + static int mac_test_externalize_label(struct label *label, char *element_name, struct sbuf *sb, int *claimed) @@ -2293,6 +2317,9 @@ .mpo_destroy_socket_label = mac_test_destroy_socket_label, .mpo_destroy_socket_peer_label = mac_test_destroy_socket_peer_label, .mpo_destroy_vnode_label = mac_test_destroy_vnode_label, + .mpo_copy_mbuf_label = mac_test_copy_mbuf_label, + .mpo_copy_pipe_label = mac_test_copy_pipe_label, + .mpo_copy_vnode_label = mac_test_copy_vnode_label, .mpo_externalize_cred_label = mac_test_externalize_label, .mpo_externalize_ifnet_label = mac_test_externalize_label, .mpo_externalize_pipe_label = mac_test_externalize_label, From owner-p4-projects@FreeBSD.ORG Sun Nov 16 09:16:11 2003 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id DB25F16A4D0; Sun, 16 Nov 2003 09:16:10 -0800 (PST) Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id B644616A4CE for ; Sun, 16 Nov 2003 09:16:10 -0800 (PST) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id EC3E343F3F for ; Sun, 16 Nov 2003 09:16:09 -0800 (PST) (envelope-from peter@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.12.9/8.12.9) with ESMTP id hAGHG9XJ099823 for ; Sun, 16 Nov 2003 09:16:09 -0800 (PST) (envelope-from peter@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.12.9/8.12.9/Submit) id hAGHG9A6099820 for perforce@freebsd.org; Sun, 16 Nov 2003 09:16:09 -0800 (PST) (envelope-from peter@freebsd.org) Date: Sun, 16 Nov 2003 09:16:09 -0800 (PST) Message-Id: <200311161716.hAGHG9A6099820@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to peter@freebsd.org using -f From: Peter Wemm To: Perforce Change Reviews Subject: PERFORCE change 42553 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 16 Nov 2003 17:16:11 -0000 http://perforce.freebsd.org/chv.cgi?CH=42553 Change 42553 by peter@peter_overcee on 2003/11/16 09:15:56 Checkpoint before I lose it. Affected files ... .. //depot/projects/hammer/sys/amd64/amd64/mpboot.S#5 edit Differences ... ==== //depot/projects/hammer/sys/amd64/amd64/mpboot.S#5 (text+ko) ==== @@ -47,13 +47,14 @@ mov %ax, %ss /* - * Patch the descriptor table + * Find relocation base and patch the gdt descript and ljmp targets */ - xorl %eax,%eax - mov %cs, %ax - sall $4, %eax - orl %eax, bootcode-gdt+2 - orl %eax, bootdata-gdt+2 + xorl %ebx,%ebx + mov %cs, %bx + sall $4, %ebx /* %ebx is now our relocation base */ + orl %ebx, lgdt_desc-mptramp_start+2 + orl %ebx, jmp_32-mptramp_start+2 + orl %ebx, jmp_64-mptramp_start+1 /* * Load the descriptor table pointer. We'll need it when running @@ -63,65 +64,101 @@ /* Enable protected mode */ movl $CR0_PE, %eax - movl %eax, %cr0 + mov %eax, %cr0 /* * Now execute a far jump to turn on protected mode. This * causes the segment registers to turn into selectors and causes * %cs to be loaded from the gdt. + * + * The following instruction is: + * ljmpl $bootcode-gdt, $protmode-mptramp_start + * but gas cannot assemble that. And besides, we patch the targets + * in early startup and its a little clearer what we are patching. */ +jmp_32: + .byte 0x66 /* size override to 32 bits */ .byte 0xea /* opcode for far jump */ - .word protmode-mptramp_start /* offset in segment */ - .word bootcode-gdt /* index in gdt for 16 bit code */ + .long protmode-mptramp_start /* offset in segment */ + .word bootcode-gdt /* index in gdt for 32 bit code */ /* * At this point, we are running in 32 bit legacy protected mode. - * However, we have a non-zero base address in our segment registers - * so that we can remain relocatable. */ .code32 protmode: mov $bootdata-gdt, %eax mov %ax, %ds - mov %ax, %ss /* Turn on the PAE, PSE and PGE bits for when paging is enabled */ mov %cr4, %eax - orl $(CR4_PAE | CR4_PSE | CR4_PGE), %eax + orl $(CR4_PAE | CR4_PSE), %eax mov %eax, %cr4 /* + * Enable EFER.LME so that we get long mode when all the prereqs are + * in place. In this case, it turns on when CR0_PG is finally enabled. + * Pick up a few other EFER bits that we'll use need we're here. + */ + movl $MSR_EFER, %ecx + rdmsr + orl $EFER_LME | EFER_SCE | EFER_NXE, %eax + wrmsr + + /* * Point to the embedded page tables for startup. Note that this * only gets accessed after we're actually in 64 bit mode, however * we can only set the bottom 32 bits of %cr3 in this state. This * means we are required to use a temporary page table that is below - * the 4GB limit. + * the 4GB limit. %ebx is still our relocation base. We could just + * subtract 3 * PAGE_SIZE, but that would be too easy. */ - movl $(mptramp_pagetables-mptramp_start), %eax + leal mptramp_pagetables-mptramp_start(%ebx),%eax + movl (%eax), %eax mov %eax, %cr3 /* - * Enable EFER.LME so that we get long mode when all the prereqs are - * in place. In this case, it turns on when CR0_PG is finally enabled. - */ - movl $MSR_EFER, %ecx - rdmsr - orl $EFER_LME, %eax - wrmsr - - /* - * Finally, switch to 64 bit mode by enabling paging. We have + * Finally, switch to long bit mode by enabling paging. We have * to be very careful here because all the segmentation disappears * out from underneath us. The spec says we can depend on the - * subsequent pipelined long jump to execute. This is Magic. + * subsequent pipelined branch to execute, but *only if* everthing + * is still identity mapped. If any mappings change, the pipeline + * will flush. */ mov %cr0, %eax orl $CR0_PG, %eax - mov %eax, %cr3 + mov %eax, %cr0 + + /* + * At this point paging is enabled, and we are in "compatability" mode. + * We do another far jump to reload %cs with the 64 bit selector. + * %cr3 points to a 4-level page table page. + * We cannot yet jump all the way to the kernel because we can only + * specify a 32 bit linear address. So, yet another trampoline. + * + * The following instruction is: + * ljmp $kernelcode-gdt, $tramp_64-mptramp_start + * but gas cannot assemble that. And besides, we patch the targets + * in early startup and its a little clearer what we are patching. + */ +jmp_64: + .byte 0xea /* opcode for far jump */ + .long tramp_64-mptramp_start /* offset in segment */ + .word kernelcode-gdt /* index in gdt for 64 bit code */ - .byte 0xea /* opcode for far jump */ - .quad entry_64 /* 64 bit flat address */ - .word kernelcode-gdt /* selector offset */ + /* + * Yeehar! We're running in 64 bit mode! We can mostly ignore our + * segment registers, and get on with it. + * Note that we are running at the correct virtual address, but with + * a 1:1 1GB mirrored mapping over entire address space. We had better + * switch to a real %cr3 promptly so that we can get to the direct map + * space. Remember that jmp is relative and that we've been relocated, + * so use an indirect jump. + */ + .code64 +tramp_64: + movabsq $entry_64,%rax /* 64 bit immediate load */ + jmp *%rax .p2align 4,0 gdt: @@ -143,7 +180,6 @@ * This is the descriptor for the 32 bit boot code. * %cs: +A, +R, -C, DPL=0, +P, +D, +G * Accessed, Readable, Present, 32 bit, 4G granularity - * Note that the base address is patched. */ bootcode: .long 0x0000ffff @@ -158,7 +194,6 @@ * Accessed, Writeable, Expand up, Present, 32 bit, 4GB * For %ds, +D means 'default operand size is 32 bit'. * For %ss, +B means the stack register is %esp rather than %sp. - * Note that the base address is patched. */ bootdata: .long 0x0000ffff @@ -166,9 +201,14 @@ gdtend: + /* + * The address of our page table pages that the boot code + * uses to trampoline up to kernel address space. + */ .globl mptramp_pagetables mptramp_pagetables: .long 0 + /* * The pseudo descriptor for lgdt to use. */ @@ -179,19 +219,18 @@ .globl mptramp_end mptramp_end: - /* - * Yeehar! We're running in 64 bit mode! We can mostly ignore our - * segment registers, and get on with it. - * Load a basic stack pointer and jump into the kernel. - * Note that we are running at the correct virtual address, but with - * a 1:1 1GB mirrored mapping over entire address space. We had better - * switch to a real %cr3 promptly. + * From here on down is executed in the kernel .text section. + * + * Load a real %cr3 that has all the direct map stuff and switches + * off the 1GB replicated mirror. Load a stack pointer and jump + * into AP startup code in C. */ .text .code64 .p2align 4,0 entry_64: - movq $bootSTK, %rsp - pushq $init_secondary - ret + movq KPML4phys, %rax + movq %rax, %cr3 + movq bootSTK, %rsp + jmp init_secondary From owner-p4-projects@FreeBSD.ORG Sun Nov 16 09:22:19 2003 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 3721216A4D0; Sun, 16 Nov 2003 09:22:19 -0800 (PST) Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id EED5C16A4CE for ; Sun, 16 Nov 2003 09:22:18 -0800 (PST) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id 0487D43FAF for ; Sun, 16 Nov 2003 09:22:18 -0800 (PST) (envelope-from peter@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.12.9/8.12.9) with ESMTP id hAGHMHXJ000203 for ; Sun, 16 Nov 2003 09:22:17 -0800 (PST) (envelope-from peter@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.12.9/8.12.9/Submit) id hAGHMHB3000200 for perforce@freebsd.org; Sun, 16 Nov 2003 09:22:17 -0800 (PST) (envelope-from peter@freebsd.org) Date: Sun, 16 Nov 2003 09:22:17 -0800 (PST) Message-Id: <200311161722.hAGHMHB3000200@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to peter@freebsd.org using -f From: Peter Wemm To: Perforce Change Reviews Subject: PERFORCE change 42554 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 16 Nov 2003 17:22:19 -0000 http://perforce.freebsd.org/chv.cgi?CH=42554 Change 42554 by peter@peter_overcee on 2003/11/16 09:21:27 fix some bugs: - basemem is in K, not bytes (argh, not again!) - access the pagetables in KERNBASE - actually or in the pte bits - it would be useful to set %rsp to the end of the stack. - restore the warmstart vector prior to panic() so that resetting the BSP will not cause it to try and do AP startup Affected files ... .. //depot/projects/hammer/sys/amd64/amd64/mp_machdep.c#32 edit Differences ... ==== //depot/projects/hammer/sys/amd64/amd64/mp_machdep.c#32 (text+ko) ==== @@ -147,11 +147,11 @@ { bootMP_size = mptramp_end - mptramp_start; - boot_address = trunc_page(basemem); /* round down to 4k boundary */ + boot_address = trunc_page(basemem * 1024); /* round down to 4k boundary */ if ((basemem - boot_address) < bootMP_size) boot_address -= PAGE_SIZE; /* not enough, lower by 4k */ /* 3 levels of page table pages */ - mptramp_pagetables = boot_address - PAGE_SIZE * 3; + mptramp_pagetables = boot_address - (PAGE_SIZE * 3); return mptramp_pagetables; } @@ -464,26 +464,24 @@ bcopy(mptramp_start, (void *)((uintptr_t)boot_address + KERNBASE), bootMP_size); /* Locate the page tables, they'll be below the trampoline */ - pt4 = (u_int64_t *)(uintptr_t)mptramp_pagetables; + pt4 = (u_int64_t *)(uintptr_t)(mptramp_pagetables + KERNBASE); pt3 = pt4 + 512; pt2 = pt3 + 512; - printf("pt4 = %p; pt3 = %p; pt2 = %p\n", pt4, pt3, pt2); /* Create the initial 1GB replicated page tables */ for (i = 0; i < 512; i++) { /* Each slot of the level 4 pages points to the same level 3 page */ - pt4[i] = (u_int64_t)(uintptr_t)pt3; - pt4[i] = PG_V | PG_RW | PG_U; + pt4[i] = (u_int64_t)(uintptr_t)(mptramp_pagetables + PAGE_SIZE); + pt4[i] |= PG_V | PG_RW | PG_U; /* Each slot of the level 3 pages points to the same level 2 page */ - pt3[i] = (u_int64_t)(uintptr_t)pt2; - pt3[i] = PG_V | PG_RW | PG_U; + pt3[i] = (u_int64_t)(uintptr_t)(mptramp_pagetables + 2 * PAGE_SIZE); + pt3[i] |= PG_V | PG_RW | PG_U; /* The level 2 page slots are mapped with 2MB pages for 1GB. */ pt2[i] = i * (2 * 1024 * 1024); - pt2[i] = PG_V | PG_RW | PG_PS | PG_U; + pt2[i] |= PG_V | PG_RW | PG_PS | PG_U; } - printf("pagetables created\n"); /* save the current value of the warm-start vector */ mpbioswarmvec = *((u_int32_t *) WARMBOOT_OFF); @@ -491,7 +489,8 @@ mpbiosreason = inb(CMOS_DATA); /* start each AP */ - for (cpu = 0, apic_id = 0; apic_id < MAXCPU; apic_id++) { + cpu = 0; + for (apic_id = 0; apic_id < MAXCPU; apic_id++) { if (!cpu_info[apic_id].cpu_present || cpu_info[apic_id].cpu_bsp) continue; @@ -534,12 +533,15 @@ outb(CMOS_REG, BIOS_RESET); outb(CMOS_DATA, BIOS_WARM); /* 'warm-start' */ - bootSTK = bootstacks[cpu]; + bootSTK = (char *)bootstacks[cpu] + KSTACK_PAGES * PAGE_SIZE - 8; bootAP = cpu; /* attempt to start the Application Processor */ - if (!start_ap(apic_id)) + if (!start_ap(apic_id)) { + /* restore the warmstart vector */ + *(u_int32_t *) WARMBOOT_OFF = mpbioswarmvec; panic("AP #%d (PHY# %d) failed!", cpu, apic_id); + } all_cpus |= (1 << cpu); /* record AP in CPU map */ } From owner-p4-projects@FreeBSD.ORG Sun Nov 16 09:23:21 2003 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 2AC8B16A4D0; Sun, 16 Nov 2003 09:23:21 -0800 (PST) Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 00E8C16A4CE for ; Sun, 16 Nov 2003 09:23:21 -0800 (PST) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id 26DA343FA3 for ; Sun, 16 Nov 2003 09:23:20 -0800 (PST) (envelope-from bb+lists.freebsd.perforce@cyrus.watson.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.12.9/8.12.9) with ESMTP id hAGHNJXJ000411 for ; Sun, 16 Nov 2003 09:23:19 -0800 (PST) (envelope-from bb+lists.freebsd.perforce@cyrus.watson.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.12.9/8.12.9/Submit) id hAGHNJlK000408 for perforce@freebsd.org; Sun, 16 Nov 2003 09:23:19 -0800 (PST) (envelope-from bb+lists.freebsd.perforce@cyrus.watson.org) Date: Sun, 16 Nov 2003 09:23:19 -0800 (PST) Message-Id: <200311161723.hAGHNJlK000408@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to bb+lists.freebsd.perforce@cyrus.watson.org using -f From: Robert Watson To: Perforce Change Reviews Subject: PERFORCE change 42555 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 16 Nov 2003 17:23:21 -0000 http://perforce.freebsd.org/chv.cgi?CH=42555 Change 42555 by rwatson@rwatson_tislabs on 2003/11/16 09:22:22 Teach mac_get_fd() to speak DTYPE_SOCKET. To do this, we need a mac_copy_socket_label() operation, which is added to each policy that supports socket labels. This also requires socket label allocation and free to be exposed out of mac_net.c, so unstaticize. This permits MAC-aware applications to test labels on sockets in a manner consistent with pipes and files, which improves support for arbitrary redirection of stdio with MAC. Affected files ... .. //depot/projects/trustedbsd/mac/sys/i386/conf/MAC#51 edit .. //depot/projects/trustedbsd/mac/sys/kern/kern_mac.c#434 edit .. //depot/projects/trustedbsd/mac/sys/security/mac/mac_internal.h#16 edit .. //depot/projects/trustedbsd/mac/sys/security/mac/mac_net.c#15 edit .. //depot/projects/trustedbsd/mac/sys/security/mac_biba/mac_biba.c#235 edit .. //depot/projects/trustedbsd/mac/sys/security/mac_lomac/mac_lomac.c#78 edit .. //depot/projects/trustedbsd/mac/sys/security/mac_mls/mac_mls.c#189 edit .. //depot/projects/trustedbsd/mac/sys/security/mac_stub/mac_stub.c#14 edit .. //depot/projects/trustedbsd/mac/sys/security/mac_test/mac_test.c#123 edit .. //depot/projects/trustedbsd/mac/sys/sys/mac_policy.h#203 edit Differences ... ==== //depot/projects/trustedbsd/mac/sys/i386/conf/MAC#51 (text+ko) ==== @@ -32,6 +32,7 @@ options MAC #options MAC_ALWAYS_LABEL_MBUF +options MAC_BIBA options MAC_DEBUG options MAC_TEST #options MAC_STATIC ==== //depot/projects/trustedbsd/mac/sys/kern/kern_mac.c#434 (text+ko) ==== @@ -726,6 +726,7 @@ struct mac mac; struct vnode *vp; struct pipe *pipe; + struct socket *so; short label_type; int error; @@ -776,6 +777,19 @@ mac_pipe_label_free(intlabel); break; + case DTYPE_SOCKET: + so = fp->f_data; + intlabel = mac_socket_label_alloc(M_WAITOK); + mtx_lock(&Giant); /* Sockets */ + /* XXX: Socket lock here. */ + mac_copy_socket_label(so->so_label, intlabel); + /* XXX: Socket unlock here. */ + mtx_unlock(&Giant); /* Sockets */ + error = mac_externalize_socket_label(intlabel, elements, + buffer, mac.m_buflen); + mac_socket_label_free(intlabel); + break; + default: error = EINVAL; } ==== //depot/projects/trustedbsd/mac/sys/security/mac/mac_internal.h#16 (text+ko) ==== @@ -105,6 +105,8 @@ */ struct label *mac_pipe_label_alloc(void); void mac_pipe_label_free(struct label *label); +struct label *mac_socket_label_alloc(int flag); +void mac_socket_label_free(struct label *label); int mac_check_cred_relabel(struct ucred *cred, struct label *newlabel); int mac_externalize_cred_label(struct label *label, char *elements, @@ -117,6 +119,11 @@ char *outbuf, size_t outbuflen); int mac_internalize_pipe_label(struct label *label, char *string); +void mac_copy_socket_label(struct label *src, struct label *dest); +int mac_externalize_socket_label(struct label *label, char *elements, + char *outbuf, size_t outbuflen); +int mac_internalize_socket_label(struct label *label, char *string); + int mac_externalize_vnode_label(struct label *label, char *elements, char *outbuf, size_t outbuflen); int mac_internalize_vnode_label(struct label *label, char *string); ==== //depot/projects/trustedbsd/mac/sys/security/mac/mac_net.c#15 (text+ko) ==== @@ -95,9 +95,6 @@ &nmacsockets, 0, "number of sockets in use"); #endif -static void mac_socket_label_free(struct label *label); - - static struct label * mbuf_to_label(struct mbuf *mbuf) { @@ -253,7 +250,7 @@ return (0); } -static struct label * +struct label * mac_socket_label_alloc(int flag) { struct label *label; @@ -389,7 +386,7 @@ MAC_DEBUG_COUNTER_DEC(&nmacmbufs); } -static void +void mac_socket_label_free(struct label *label) { @@ -432,6 +429,13 @@ MAC_PERFORM(copy_mbuf_label, src_label, dest_label); } +void +mac_copy_socket_label(struct label *src, struct label *dest) +{ + + MAC_PERFORM(copy_socket_label, src, dest); +} + static int mac_externalize_ifnet_label(struct label *label, char *elements, char *outbuf, size_t outbuflen) @@ -443,7 +447,7 @@ return (error); } -static int +int mac_externalize_socket_label(struct label *label, char *elements, char *outbuf, size_t outbuflen) { @@ -475,7 +479,7 @@ return (error); } -static int +int mac_internalize_socket_label(struct label *label, char *string) { int error; ==== //depot/projects/trustedbsd/mac/sys/security/mac_biba/mac_biba.c#235 (text+ko) ==== @@ -3186,6 +3186,7 @@ .mpo_destroy_vnode_label = mac_biba_destroy_label, .mpo_copy_mbuf_label = mac_biba_copy_label, .mpo_copy_pipe_label = mac_biba_copy_label, + .mpo_copy_socket_label = mac_biba_copy_label, .mpo_copy_vnode_label = mac_biba_copy_label, .mpo_externalize_cred_label = mac_biba_externalize_label, .mpo_externalize_ifnet_label = mac_biba_externalize_label, ==== //depot/projects/trustedbsd/mac/sys/security/mac_lomac/mac_lomac.c#78 (text+ko) ==== @@ -3114,6 +3114,7 @@ .mpo_destroy_vnode_label = mac_lomac_destroy_label, .mpo_copy_mbuf_label = mac_lomac_copy_label, .mpo_copy_pipe_label = mac_lomac_copy_label, + .mpo_copy_socket_label = mac_lomac_copy_label, .mpo_copy_vnode_label = mac_lomac_copy_label, .mpo_externalize_cred_label = mac_lomac_externalize_label, .mpo_externalize_ifnet_label = mac_lomac_externalize_label, ==== //depot/projects/trustedbsd/mac/sys/security/mac_mls/mac_mls.c#189 (text+ko) ==== @@ -2963,6 +2963,7 @@ .mpo_destroy_vnode_label = mac_mls_destroy_label, .mpo_copy_mbuf_label = mac_mls_copy_label, .mpo_copy_pipe_label = mac_mls_copy_label, + .mpo_copy_socket_label = mac_mls_copy_label, .mpo_copy_vnode_label = mac_mls_copy_label, .mpo_externalize_cred_label = mac_mls_externalize_label, .mpo_externalize_ifnet_label = mac_mls_externalize_label, ==== //depot/projects/trustedbsd/mac/sys/security/mac_stub/mac_stub.c#14 (text+ko) ==== @@ -1328,6 +1328,7 @@ .mpo_destroy_vnode_label = stub_destroy_label, .mpo_copy_mbuf_label = stub_copy_label, .mpo_copy_pipe_label = stub_copy_label, + .mpo_copy_socket_label = stub_copy_label, .mpo_copy_vnode_label = stub_copy_label, .mpo_externalize_cred_label = stub_externalize_label, .mpo_externalize_ifnet_label = stub_externalize_label, ==== //depot/projects/trustedbsd/mac/sys/security/mac_test/mac_test.c#123 (text+ko) ==== @@ -764,6 +764,14 @@ } static void +mac_test_copy_socket_label(struct label *src, struct label *dest) +{ + + ASSERT_SOCKET_LABEL(src); + ASSERT_SOCKET_LABEL(dest); +} + +static void mac_test_copy_vnode_label(struct label *src, struct label *dest) { @@ -2319,6 +2327,7 @@ .mpo_destroy_vnode_label = mac_test_destroy_vnode_label, .mpo_copy_mbuf_label = mac_test_copy_mbuf_label, .mpo_copy_pipe_label = mac_test_copy_pipe_label, + .mpo_copy_socket_label = mac_test_copy_socket_label, .mpo_copy_vnode_label = mac_test_copy_vnode_label, .mpo_externalize_cred_label = mac_test_externalize_label, .mpo_externalize_ifnet_label = mac_test_externalize_label, ==== //depot/projects/trustedbsd/mac/sys/sys/mac_policy.h#203 (text+ko) ==== @@ -125,6 +125,8 @@ struct label *dest); void (*mpo_copy_pipe_label)(struct label *src, struct label *dest); + void (*mpo_copy_socket_label)(struct label *src, + struct label *dest); void (*mpo_copy_vnode_label)(struct label *src, struct label *dest); int (*mpo_externalize_cred_label)(struct label *label, From owner-p4-projects@FreeBSD.ORG Sun Nov 16 09:45:49 2003 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id B7BF716A4D0; Sun, 16 Nov 2003 09:45:49 -0800 (PST) Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 6440D16A4CE for ; Sun, 16 Nov 2003 09:45:49 -0800 (PST) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id B0D5D43F75 for ; Sun, 16 Nov 2003 09:45:48 -0800 (PST) (envelope-from bb+lists.freebsd.perforce@cyrus.watson.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.12.9/8.12.9) with ESMTP id hAGHjmXJ001350 for ; Sun, 16 Nov 2003 09:45:48 -0800 (PST) (envelope-from bb+lists.freebsd.perforce@cyrus.watson.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.12.9/8.12.9/Submit) id hAGHjmrU001347 for perforce@freebsd.org; Sun, 16 Nov 2003 09:45:48 -0800 (PST) (envelope-from bb+lists.freebsd.perforce@cyrus.watson.org) Date: Sun, 16 Nov 2003 09:45:48 -0800 (PST) Message-Id: <200311161745.hAGHjmrU001347@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to bb+lists.freebsd.perforce@cyrus.watson.org using -f From: Robert Watson To: Perforce Change Reviews Subject: PERFORCE change 42557 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 16 Nov 2003 17:45:50 -0000 http://perforce.freebsd.org/chv.cgi?CH=42557 Change 42557 by rwatson@rwatson_tislabs on 2003/11/16 09:45:41 Reduce gratuitous redundancy and length in function names: mac_setsockopt_label_set() -> mac_setsockopt_label() mac_getsockopt_label_get() -> mac_getsockopt_label() mac_getsockopt_peerlabel_get() -> mac_getsockopt_peerlabel() Affected files ... .. //depot/projects/trustedbsd/mac/sys/kern/uipc_socket.c#56 edit .. //depot/projects/trustedbsd/mac/sys/security/mac/mac_net.c#16 edit .. //depot/projects/trustedbsd/mac/sys/sys/mac.h#253 edit Differences ... ==== //depot/projects/trustedbsd/mac/sys/kern/uipc_socket.c#56 (text+ko) ==== @@ -1452,10 +1452,8 @@ sizeof extmac); if (error) goto bad; - - error = mac_setsockopt_label_set( - sopt->sopt_td->td_ucred, so, &extmac); - + error = mac_setsockopt_label(sopt->sopt_td->td_ucred, + so, &extmac); #else error = EOPNOTSUPP; #endif @@ -1603,8 +1601,8 @@ sizeof(extmac)); if (error) return (error); - error = mac_getsockopt_label_get( - sopt->sopt_td->td_ucred, so, &extmac); + error = mac_getsockopt_label(sopt->sopt_td->td_ucred, + so, &extmac); if (error) return (error); error = sooptcopyout(sopt, &extmac, sizeof extmac); @@ -1618,7 +1616,7 @@ sizeof(extmac)); if (error) return (error); - error = mac_getsockopt_peerlabel_get( + error = mac_getsockopt_peerlabel( sopt->sopt_td->td_ucred, so, &extmac); if (error) return (error); ==== //depot/projects/trustedbsd/mac/sys/security/mac/mac_net.c#16 (text+ko) ==== @@ -994,8 +994,7 @@ } int -mac_setsockopt_label_set(struct ucred *cred, struct socket *so, - struct mac *mac) +mac_setsockopt_label(struct ucred *cred, struct socket *so, struct mac *mac) { struct label *intlabel; char *buffer; @@ -1044,8 +1043,7 @@ } int -mac_getsockopt_label_get(struct ucred *cred, struct socket *so, - struct mac *mac) +mac_getsockopt_label(struct ucred *cred, struct socket *so, struct mac *mac) { char *buffer, *elements; int error; @@ -1074,7 +1072,7 @@ } int -mac_getsockopt_peerlabel_get(struct ucred *cred, struct socket *so, +mac_getsockopt_peerlabel(struct ucred *cred, struct socket *so, struct mac *mac) { char *elements, *buffer; ==== //depot/projects/trustedbsd/mac/sys/sys/mac.h#253 (text+ko) ==== @@ -424,15 +424,15 @@ struct ucred *file_cred, struct vnode *vp); int mac_check_vnode_write(struct ucred *active_cred, struct ucred *file_cred, struct vnode *vp); -int mac_getsockopt_label_get(struct ucred *cred, struct socket *so, +int mac_getsockopt_label(struct ucred *cred, struct socket *so, struct mac *extmac); -int mac_getsockopt_peerlabel_get(struct ucred *cred, struct socket *so, +int mac_getsockopt_peerlabel(struct ucred *cred, struct socket *so, struct mac *extmac); int mac_ioctl_ifnet_get(struct ucred *cred, struct ifreq *ifr, struct ifnet *ifnet); int mac_ioctl_ifnet_set(struct ucred *cred, struct ifreq *ifr, struct ifnet *ifnet); -int mac_setsockopt_label_set(struct ucred *cred, struct socket *so, +int mac_setsockopt_label(struct ucred *cred, struct socket *so, struct mac *extmac); int mac_pipe_label_set(struct ucred *cred, struct pipe *pipe, struct label *label); From owner-p4-projects@FreeBSD.ORG Sun Nov 16 09:51:58 2003 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id DC34616A4D0; Sun, 16 Nov 2003 09:51:57 -0800 (PST) Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id B511216A4CE for ; Sun, 16 Nov 2003 09:51:57 -0800 (PST) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id 1886843FDD for ; Sun, 16 Nov 2003 09:51:57 -0800 (PST) (envelope-from bb+lists.freebsd.perforce@cyrus.watson.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.12.9/8.12.9) with ESMTP id hAGHpuXJ001720 for ; Sun, 16 Nov 2003 09:51:56 -0800 (PST) (envelope-from bb+lists.freebsd.perforce@cyrus.watson.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.12.9/8.12.9/Submit) id hAGHpugc001717 for perforce@freebsd.org; Sun, 16 Nov 2003 09:51:56 -0800 (PST) (envelope-from bb+lists.freebsd.perforce@cyrus.watson.org) Date: Sun, 16 Nov 2003 09:51:56 -0800 (PST) Message-Id: <200311161751.hAGHpugc001717@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to bb+lists.freebsd.perforce@cyrus.watson.org using -f From: Robert Watson To: Perforce Change Reviews Subject: PERFORCE change 42558 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 16 Nov 2003 17:51:58 -0000 http://perforce.freebsd.org/chv.cgi?CH=42558 Change 42558 by rwatson@rwatson_tislabs on 2003/11/16 09:51:10 Implement mac_get_peer() in terms of getsockopt(..., SO_PEERLABEL, ...); This provides an API for retrieving socket peer labels that is ABI-neutral concerning the definition of mac_t. Previously, MAC-aware applications had to be able to include sizeof(*mac_t) as an argument to getsockopt(), building binary dependencies into application code that would limit future changes to struct mac. Affected files ... .. //depot/projects/trustedbsd/mac/lib/libc/posix1e/mac.c#14 edit .. //depot/projects/trustedbsd/mac/lib/libc/posix1e/mac_get.c#13 edit .. //depot/projects/trustedbsd/mac/sys/sys/mac.h#254 edit Differences ... ==== //depot/projects/trustedbsd/mac/lib/libc/posix1e/mac.c#14 (text+ko) ==== ==== //depot/projects/trustedbsd/mac/lib/libc/posix1e/mac_get.c#13 (text+ko) ==== @@ -33,6 +33,7 @@ #include #include +#include extern int __mac_get_fd(int fd, struct mac *mac_p); extern int __mac_get_file(const char *path_p, struct mac *mac_p); @@ -61,6 +62,15 @@ return (__mac_get_link(path, label)); } + +int +mac_get_peer(int fd, struct mac *label) +{ + socklen_t len; + + len = sizeof(*label); + return (getsockopt(fd, SOL_SOCKET, SO_PEERLABEL, label, &len)); +} int mac_get_pid(pid_t pid, struct mac *label) { ==== //depot/projects/trustedbsd/mac/sys/sys/mac.h#254 (text+ko) ==== @@ -84,6 +84,7 @@ int mac_get_fd(int _fd, mac_t _label); int mac_get_file(const char *_path, mac_t _label); int mac_get_link(const char *_path, mac_t _label); +int mac_get_peer(int _fd, mac_t _label); int mac_get_pid(pid_t _pid, mac_t _label); int mac_get_proc(mac_t _label); int mac_is_present(const char *_policyname); From owner-p4-projects@FreeBSD.ORG Sun Nov 16 10:11:22 2003 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 2D31A16A4D0; Sun, 16 Nov 2003 10:11:22 -0800 (PST) Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id D96AC16A4CE for ; Sun, 16 Nov 2003 10:11:21 -0800 (PST) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id 2DEC643FBF for ; Sun, 16 Nov 2003 10:11:21 -0800 (PST) (envelope-from bb+lists.freebsd.perforce@cyrus.watson.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.12.9/8.12.9) with ESMTP id hAGIBLXJ003562 for ; Sun, 16 Nov 2003 10:11:21 -0800 (PST) (envelope-from bb+lists.freebsd.perforce@cyrus.watson.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.12.9/8.12.9/Submit) id hAGIBKJX003559 for perforce@freebsd.org; Sun, 16 Nov 2003 10:11:20 -0800 (PST) (envelope-from bb+lists.freebsd.perforce@cyrus.watson.org) Date: Sun, 16 Nov 2003 10:11:20 -0800 (PST) Message-Id: <200311161811.hAGIBKJX003559@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to bb+lists.freebsd.perforce@cyrus.watson.org using -f From: Robert Watson To: Perforce Change Reviews Subject: PERFORCE change 42559 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 16 Nov 2003 18:11:22 -0000 http://perforce.freebsd.org/chv.cgi?CH=42559 Change 42559 by rwatson@rwatson_tislabs on 2003/11/16 10:10:34 Implement support for mac_set_fd() for sockets, allowing MAC-aware programs to treat sockets in the same manner as pipes, fifos, and vnodes. To do this, abstract check/set logic for socket labels from mac_setsockopt_label() into mac_socket_label_set() congruent to mac_pipe_label_set(). Affected files ... .. //depot/projects/trustedbsd/mac/sys/kern/kern_mac.c#435 edit .. //depot/projects/trustedbsd/mac/sys/security/mac/mac_internal.h#17 edit .. //depot/projects/trustedbsd/mac/sys/security/mac/mac_net.c#17 edit Differences ... ==== //depot/projects/trustedbsd/mac/sys/kern/kern_mac.c#435 (text+ko) ==== @@ -920,6 +920,7 @@ { struct label *intlabel; struct pipe *pipe; + struct socket *so; struct file *fp; struct mount *mp; struct vnode *vp; @@ -984,6 +985,21 @@ mac_pipe_label_free(intlabel); break; + case DTYPE_SOCKET: + intlabel = mac_socket_label_alloc(M_WAITOK); + error = mac_internalize_socket_label(intlabel, buffer); + if (error == 0) { + so = fp->f_data; + mtx_lock(&Giant); /* Sockets */ + /* XXX: Socket lock here. */ + error = mac_socket_label_set(td->td_ucred, so, + intlabel); + /* XXX: Socket unlock here. */ + mtx_unlock(&Giant); /* Sockets */ + } + mac_socket_label_free(intlabel); + break; + default: error = EINVAL; } ==== //depot/projects/trustedbsd/mac/sys/security/mac/mac_internal.h#17 (text+ko) ==== @@ -119,6 +119,8 @@ char *outbuf, size_t outbuflen); int mac_internalize_pipe_label(struct label *label, char *string); +int mac_socket_label_set(struct ucred *cred, struct socket *so, + struct label *label); void mac_copy_socket_label(struct label *src, struct label *dest); int mac_externalize_socket_label(struct label *label, char *elements, char *outbuf, size_t outbuflen); ==== //depot/projects/trustedbsd/mac/sys/security/mac/mac_net.c#17 (text+ko) ==== @@ -994,6 +994,30 @@ } int +mac_socket_label_set(struct ucred *cred, struct socket *so, + struct label *label) +{ + int error; + + error = mac_check_socket_relabel(cred, so, label); + if (error) + return (error); + + mac_relabel_socket(cred, so, label); + + /* + * If the protocol has expressed interest in socket layer changes, + * such as if it needs to propagate changes to a cached pcb + * label from the socket, notify it of the label change while + * holding the socket lock. + */ + if (so->so_proto->pr_usrreqs->pru_sosetlabel != NULL) + (so->so_proto->pr_usrreqs->pru_sosetlabel)(so); + + return (0); +} + +int mac_setsockopt_label(struct ucred *cred, struct socket *so, struct mac *mac) { struct label *intlabel; @@ -1014,32 +1038,15 @@ intlabel = mac_socket_label_alloc(M_WAITOK); error = mac_internalize_socket_label(intlabel, buffer); free(buffer, M_MACTEMP); - if (error) { - mac_socket_label_free(intlabel); - return (error); - } + if (error) + goto out; - /* XXX: Will eventually grab a socket lock here. */ - mac_check_socket_relabel(cred, so, intlabel); - if (error) { - mac_socket_label_free(intlabel); - return (error); - } - - mac_relabel_socket(cred, so, intlabel); - - /* - * If the protocol has expressed interest in socket layer changes, - * such as if it needs to propagate changes to a cached pcb - * label from the socket, notify it of the label change while - * holding the socket lock. - */ - if (so->so_proto->pr_usrreqs->pru_sosetlabel != NULL) - (so->so_proto->pr_usrreqs->pru_sosetlabel)(so); - /* XXX: Will eventually release a socket lock here. */ - + /* XXX: Socket lock here. */ + error = mac_socket_label_set(cred, so, intlabel); + /* XXX: Socket unlock here. */ +out: mac_socket_label_free(intlabel); - return (0); + return (error); } int From owner-p4-projects@FreeBSD.ORG Sun Nov 16 11:38:10 2003 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 641FC16A4D0; Sun, 16 Nov 2003 11:38:10 -0800 (PST) Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 396E816A4CE for ; Sun, 16 Nov 2003 11:38:10 -0800 (PST) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id 932EB43FA3 for ; Sun, 16 Nov 2003 11:38:09 -0800 (PST) (envelope-from peter@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.12.9/8.12.9) with ESMTP id hAGJc9XJ008677 for ; Sun, 16 Nov 2003 11:38:09 -0800 (PST) (envelope-from peter@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.12.9/8.12.9/Submit) id hAGJc9ui008674 for perforce@freebsd.org; Sun, 16 Nov 2003 11:38:09 -0800 (PST) (envelope-from peter@freebsd.org) Date: Sun, 16 Nov 2003 11:38:09 -0800 (PST) Message-Id: <200311161938.hAGJc9ui008674@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to peter@freebsd.org using -f From: Peter Wemm To: Perforce Change Reviews Subject: PERFORCE change 42564 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 16 Nov 2003 19:38:10 -0000 http://perforce.freebsd.org/chv.cgi?CH=42564 Change 42564 by peter@peter_overcee on 2003/11/16 11:37:27 DOH!!!! this might help. Affected files ... .. //depot/projects/hammer/sys/amd64/include/atomic.h#6 edit Differences ... ==== //depot/projects/hammer/sys/amd64/include/atomic.h#6 (text+ko) ==== @@ -82,7 +82,7 @@ * For userland, assume the SMP case and use lock prefixes so that * the binaries will run on both types of systems. */ -#if !defined(_KERNEL) +#if defined(SMP) || !defined(_KERNEL) #define MPLOCKED lock ; #else #define MPLOCKED From owner-p4-projects@FreeBSD.ORG Sun Nov 16 13:35:38 2003 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id C5FAE16A4D1; Sun, 16 Nov 2003 13:35:37 -0800 (PST) Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id A18B716A4CE for ; Sun, 16 Nov 2003 13:35:37 -0800 (PST) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id B51E543FEA for ; Sun, 16 Nov 2003 13:35:36 -0800 (PST) (envelope-from peter@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.12.9/8.12.9) with ESMTP id hAGLZaXJ021497 for ; Sun, 16 Nov 2003 13:35:36 -0800 (PST) (envelope-from peter@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.12.9/8.12.9/Submit) id hAGLZZto021494 for perforce@freebsd.org; Sun, 16 Nov 2003 13:35:35 -0800 (PST) (envelope-from peter@freebsd.org) Date: Sun, 16 Nov 2003 13:35:35 -0800 (PST) Message-Id: <200311162135.hAGLZZto021494@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to peter@freebsd.org using -f From: Peter Wemm To: Perforce Change Reviews Subject: PERFORCE change 42570 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 16 Nov 2003 21:35:38 -0000 http://perforce.freebsd.org/chv.cgi?CH=42570 Change 42570 by peter@peter_overcee on 2003/11/16 13:35:11 get rid of leftover timer0 fudgery oops. add back forward_hardclock() call for SMP Affected files ... .. //depot/projects/hammer/sys/amd64/isa/clock.c#15 edit Differences ... ==== //depot/projects/hammer/sys/amd64/isa/clock.c#15 (text+ko) ==== @@ -125,7 +125,6 @@ #define ACQUIRE_PENDING 3 static u_char timer2_state; -static void (*timer_func)(struct clockframe *frame) = hardclock; static unsigned i8254_get_timecount(struct timecounter *tc); static void set_timer_freq(u_int freq, int intr_freq); @@ -154,7 +153,10 @@ clkintr_pending = 0; mtx_unlock_spin(&clock_lock); } - timer_func(frame); + hardclock(frame); +#ifdef SMP + forward_hardclock(); +#endif } int From owner-p4-projects@FreeBSD.ORG Sun Nov 16 13:36:39 2003 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id A792616A4D0; Sun, 16 Nov 2003 13:36:39 -0800 (PST) Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 8086F16A4CE for ; Sun, 16 Nov 2003 13:36:39 -0800 (PST) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id DA0B343F85 for ; Sun, 16 Nov 2003 13:36:38 -0800 (PST) (envelope-from peter@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.12.9/8.12.9) with ESMTP id hAGLacXJ021531 for ; Sun, 16 Nov 2003 13:36:38 -0800 (PST) (envelope-from peter@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.12.9/8.12.9/Submit) id hAGLacw8021528 for perforce@freebsd.org; Sun, 16 Nov 2003 13:36:38 -0800 (PST) (envelope-from peter@freebsd.org) Date: Sun, 16 Nov 2003 13:36:38 -0800 (PST) Message-Id: <200311162136.hAGLacw8021528@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to peter@freebsd.org using -f From: Peter Wemm To: Perforce Change Reviews Subject: PERFORCE change 42571 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 16 Nov 2003 21:36:40 -0000 http://perforce.freebsd.org/chv.cgi?CH=42571 Change 42571 by peter@peter_overcee on 2003/11/16 13:36:10 hack! hack! not that I dont trust pcpu, but I just wanted to be damn sure. Affected files ... .. //depot/projects/hammer/sys/kern/kern_ktr.c#8 edit Differences ... ==== //depot/projects/hammer/sys/kern/kern_ktr.c#8 (text+ko) ==== @@ -55,6 +55,12 @@ #include #endif +#ifdef __amd64__ +#include +#include +#include +#define KTR_CPU lapic_id() +#endif #include From owner-p4-projects@FreeBSD.ORG Sun Nov 16 13:37:41 2003 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 9987916A4D0; Sun, 16 Nov 2003 13:37:41 -0800 (PST) Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 748AC16A4CE for ; Sun, 16 Nov 2003 13:37:41 -0800 (PST) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id CD00143FBF for ; Sun, 16 Nov 2003 13:37:40 -0800 (PST) (envelope-from peter@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.12.9/8.12.9) with ESMTP id hAGLbeXJ021564 for ; Sun, 16 Nov 2003 13:37:40 -0800 (PST) (envelope-from peter@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.12.9/8.12.9/Submit) id hAGLbe1w021561 for perforce@freebsd.org; Sun, 16 Nov 2003 13:37:40 -0800 (PST) (envelope-from peter@freebsd.org) Date: Sun, 16 Nov 2003 13:37:40 -0800 (PST) Message-Id: <200311162137.hAGLbe1w021561@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to peter@freebsd.org using -f From: Peter Wemm To: Perforce Change Reviews Subject: PERFORCE change 42572 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 16 Nov 2003 21:37:42 -0000 http://perforce.freebsd.org/chv.cgi?CH=42572 Change 42572 by peter@peter_overcee on 2003/11/16 13:37:21 allow lapic_id() to be called before everything is up and running. this is needed for the ktr hack note to self: DO NOT COMMIT THIS! Affected files ... .. //depot/projects/hammer/sys/amd64/amd64/local_apic.c#22 edit Differences ... ==== //depot/projects/hammer/sys/amd64/amd64/local_apic.c#22 (text+ko) ==== @@ -304,7 +304,12 @@ lapic_id(void) { +#if 0 KASSERT(lapic != NULL, ("local APIC is not mapped")); +#else + if (lapic == 0) + return 0; +#endif return (lapic->id >> APIC_ID_SHIFT); } From owner-p4-projects@FreeBSD.ORG Sun Nov 16 13:39:46 2003 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id E849916A4D1; Sun, 16 Nov 2003 13:39:45 -0800 (PST) Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id C187516A4CE for ; Sun, 16 Nov 2003 13:39:45 -0800 (PST) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id D54AD43F75 for ; Sun, 16 Nov 2003 13:39:44 -0800 (PST) (envelope-from peter@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.12.9/8.12.9) with ESMTP id hAGLdiXJ021665 for ; Sun, 16 Nov 2003 13:39:44 -0800 (PST) (envelope-from peter@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.12.9/8.12.9/Submit) id hAGLdiXm021662 for perforce@freebsd.org; Sun, 16 Nov 2003 13:39:44 -0800 (PST) (envelope-from peter@freebsd.org) Date: Sun, 16 Nov 2003 13:39:44 -0800 (PST) Message-Id: <200311162139.hAGLdiXm021662@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to peter@freebsd.org using -f From: Peter Wemm To: Perforce Change Reviews Subject: PERFORCE change 42574 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 16 Nov 2003 21:39:46 -0000 http://perforce.freebsd.org/chv.cgi?CH=42574 Change 42574 by peter@peter_overcee on 2003/11/16 13:38:42 add a pc_tssp to point to the per-cpu tss struct with the conventional tss_rsp0 value that is used when a trap or interrupt causes kernel entry. add a pc_rsp0 for the fast_syscall entry point. Affected files ... .. //depot/projects/hammer/sys/amd64/include/pcpu.h#13 edit Differences ... ==== //depot/projects/hammer/sys/amd64/include/pcpu.h#13 (text+ko) ==== @@ -41,6 +41,8 @@ #define PCPU_MD_FIELDS \ struct pcpu *pc_prvspace; /* Self-reference */ \ struct pmap *pc_curpmap; \ + struct amd64tss *pc_tssp; \ + register_t pc_rsp0; \ register_t pc_scratch_rsp; /* User %rsp in syscall */ \ u_int pc_apic_id; \ u_int pc_acpi_id; /* ACPI CPU id */ From owner-p4-projects@FreeBSD.ORG Sun Nov 16 13:39:46 2003 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 20A3516A4ED; Sun, 16 Nov 2003 13:39:46 -0800 (PST) Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id E73A616A4D0 for ; Sun, 16 Nov 2003 13:39:45 -0800 (PST) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id 49BC043FCB for ; Sun, 16 Nov 2003 13:39:45 -0800 (PST) (envelope-from peter@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.12.9/8.12.9) with ESMTP id hAGLdjXJ021671 for ; Sun, 16 Nov 2003 13:39:45 -0800 (PST) (envelope-from peter@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.12.9/8.12.9/Submit) id hAGLdiOu021668 for perforce@freebsd.org; Sun, 16 Nov 2003 13:39:44 -0800 (PST) (envelope-from peter@freebsd.org) Date: Sun, 16 Nov 2003 13:39:44 -0800 (PST) Message-Id: <200311162139.hAGLdiOu021668@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to peter@freebsd.org using -f From: Peter Wemm To: Perforce Change Reviews Subject: PERFORCE change 42575 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 16 Nov 2003 21:39:46 -0000 http://perforce.freebsd.org/chv.cgi?CH=42575 Change 42575 by peter@peter_overcee on 2003/11/16 13:39:19 export PC_TSSP and PC_RSP0. Still not quite final yet. Affected files ... .. //depot/projects/hammer/sys/amd64/amd64/genassym.c#25 edit Differences ... ==== //depot/projects/hammer/sys/amd64/amd64/genassym.c#25 (text+ko) ==== @@ -188,6 +188,8 @@ ASSYM(PC_CPUID, offsetof(struct pcpu, pc_cpuid)); ASSYM(PC_SCRATCH_RSP, offsetof(struct pcpu, pc_scratch_rsp)); ASSYM(PC_CURPMAP, offsetof(struct pcpu, pc_curpmap)); +ASSYM(PC_TSSP, offsetof(struct pcpu, pc_tssp)); +ASSYM(PC_RSP0, offsetof(struct pcpu, pc_rsp0)); ASSYM(LA_VER, offsetof(struct LAPIC, version)); ASSYM(LA_TPR, offsetof(struct LAPIC, tpr)); From owner-p4-projects@FreeBSD.ORG Sun Nov 16 13:40:48 2003 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 008A416A4D1; Sun, 16 Nov 2003 13:40:47 -0800 (PST) Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id CEA1416A4CF for ; Sun, 16 Nov 2003 13:40:47 -0800 (PST) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id 48F1C43FAF for ; Sun, 16 Nov 2003 13:40:47 -0800 (PST) (envelope-from peter@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.12.9/8.12.9) with ESMTP id hAGLelXJ021865 for ; Sun, 16 Nov 2003 13:40:47 -0800 (PST) (envelope-from peter@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.12.9/8.12.9/Submit) id hAGLekKl021857 for perforce@freebsd.org; Sun, 16 Nov 2003 13:40:46 -0800 (PST) (envelope-from peter@freebsd.org) Date: Sun, 16 Nov 2003 13:40:46 -0800 (PST) Message-Id: <200311162140.hAGLekKl021857@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to peter@freebsd.org using -f From: Peter Wemm To: Perforce Change Reviews Subject: PERFORCE change 42576 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 16 Nov 2003 21:40:48 -0000 X-List-Received-Date: Sun, 16 Nov 2003 21:40:48 -0000 http://perforce.freebsd.org/chv.cgi?CH=42576 Change 42576 by peter@peter_overcee on 2003/11/16 13:40:07 update the tss_rsp0 and pc_rsp0. the more expensive form should be #ifdef SMP Affected files ... .. //depot/projects/hammer/sys/amd64/amd64/cpu_switch.S#11 edit Differences ... ==== //depot/projects/hammer/sys/amd64/amd64/cpu_switch.S#11 (text+ko) ==== @@ -201,8 +201,11 @@ wrmsr /* Update the TSS_RSP0 pointer for the next interrupt */ + movq PCPU(TSSP), %rax + addq $COMMON_TSS_RSP0, %rax leaq -16(%r8), %rbx - movq %rbx, common_tss + COMMON_TSS_RSP0 + movq %rbx, (%rax) + movq %rbx, PCPU(RSP0) /* Restore context. */ movq PCB_RBX(%r8),%rbx From owner-p4-projects@FreeBSD.ORG Sun Nov 16 13:40:48 2003 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 9128B16A4D4; Sun, 16 Nov 2003 13:40:48 -0800 (PST) Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 6809216A4DA for ; Sun, 16 Nov 2003 13:40:48 -0800 (PST) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id C27D943FB1 for ; Sun, 16 Nov 2003 13:40:47 -0800 (PST) (envelope-from peter@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.12.9/8.12.9) with ESMTP id hAGLelXJ021878 for ; Sun, 16 Nov 2003 13:40:47 -0800 (PST) (envelope-from peter@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.12.9/8.12.9/Submit) id hAGLel5D021870 for perforce@freebsd.org; Sun, 16 Nov 2003 13:40:47 -0800 (PST) (envelope-from peter@freebsd.org) Date: Sun, 16 Nov 2003 13:40:47 -0800 (PST) Message-Id: <200311162140.hAGLel5D021870@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to peter@freebsd.org using -f From: Peter Wemm To: Perforce Change Reviews Subject: PERFORCE change 42577 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 16 Nov 2003 21:40:49 -0000 http://perforce.freebsd.org/chv.cgi?CH=42577 Change 42577 by peter@peter_overcee on 2003/11/16 13:40:41 initialize the stack from pcpu->pc_rsp0 on fast_syscall Affected files ... .. //depot/projects/hammer/sys/amd64/amd64/exception.S#22 edit Differences ... ==== //depot/projects/hammer/sys/amd64/amd64/exception.S#22 (text+ko) ==== @@ -218,7 +218,7 @@ IDTVEC(fast_syscall) swapgs movq %rsp,PCPU(SCRATCH_RSP) - movq common_tss+COMMON_TSS_RSP0,%rsp + movq PCPU(RSP0),%rsp /* Now emulate a trapframe. Make the 8 byte alignment odd for call. */ subq $TF_SIZE,%rsp /* defer TF_RSP till we have a spare register */ From owner-p4-projects@FreeBSD.ORG Sun Nov 16 13:41:51 2003 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id BCE0616A4D0; Sun, 16 Nov 2003 13:41:50 -0800 (PST) Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 7BE3F16A4CE for ; Sun, 16 Nov 2003 13:41:50 -0800 (PST) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id A48E343FE9 for ; Sun, 16 Nov 2003 13:41:49 -0800 (PST) (envelope-from peter@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.12.9/8.12.9) with ESMTP id hAGLfnXJ021919 for ; Sun, 16 Nov 2003 13:41:49 -0800 (PST) (envelope-from peter@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.12.9/8.12.9/Submit) id hAGLfnSg021916 for perforce@freebsd.org; Sun, 16 Nov 2003 13:41:49 -0800 (PST) (envelope-from peter@freebsd.org) Date: Sun, 16 Nov 2003 13:41:49 -0800 (PST) Message-Id: <200311162141.hAGLfnSg021916@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to peter@freebsd.org using -f From: Peter Wemm To: Perforce Change Reviews Subject: PERFORCE change 42578 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 16 Nov 2003 21:41:51 -0000 http://perforce.freebsd.org/chv.cgi?CH=42578 Change 42578 by peter@peter_overcee on 2003/11/16 13:41:09 prime pc_tssp and pc_rsp0 on the BSP Affected files ... .. //depot/projects/hammer/sys/amd64/amd64/machdep.c#69 edit Differences ... ==== //depot/projects/hammer/sys/amd64/amd64/machdep.c#69 (text+ko) ==== @@ -1138,6 +1138,7 @@ pcpu_init(pc, 0, sizeof(struct pcpu)); PCPU_SET(prvspace, pc); PCPU_SET(curthread, &thread0); + PCPU_SET(tssp, &common_tss[0]); /* * Initialize mutexes. @@ -1201,6 +1202,7 @@ KSTACK_PAGES * PAGE_SIZE - sizeof(struct pcb); /* Ensure the stack is aligned to 16 bytes */ common_tss[0].tss_rsp0 &= ~0xF; + PCPU_SET(rsp0, common_tss[0].tss_rsp0); /* doublefault stack space, runs on ist1 */ common_tss[0].tss_ist1 = (long)&dblfault_stack[sizeof(dblfault_stack)]; From owner-p4-projects@FreeBSD.ORG Sun Nov 16 13:42:54 2003 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 02E1216A4D0; Sun, 16 Nov 2003 13:42:54 -0800 (PST) Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id D20AD16A4CE for ; Sun, 16 Nov 2003 13:42:53 -0800 (PST) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id A872A43FBD for ; Sun, 16 Nov 2003 13:42:51 -0800 (PST) (envelope-from peter@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.12.9/8.12.9) with ESMTP id hAGLgpXJ022048 for ; Sun, 16 Nov 2003 13:42:51 -0800 (PST) (envelope-from peter@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.12.9/8.12.9/Submit) id hAGLgpWg022045 for perforce@freebsd.org; Sun, 16 Nov 2003 13:42:51 -0800 (PST) (envelope-from peter@freebsd.org) Date: Sun, 16 Nov 2003 13:42:51 -0800 (PST) Message-Id: <200311162142.hAGLgpWg022045@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to peter@freebsd.org using -f From: Peter Wemm To: Perforce Change Reviews Subject: PERFORCE change 42581 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 16 Nov 2003 21:42:54 -0000 http://perforce.freebsd.org/chv.cgi?CH=42581 Change 42581 by peter@peter_overcee on 2003/11/16 13:41:58 checkpoint, with all its WIP in full glory. Affected files ... .. //depot/projects/hammer/sys/amd64/amd64/mp_machdep.c#33 edit Differences ... ==== //depot/projects/hammer/sys/amd64/amd64/mp_machdep.c#33 (text+ko) ==== @@ -1,5 +1,6 @@ /*- * Copyright (c) 1996, by Steve Passe + * Copyright (c) 2003, by Steve Passe * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -104,6 +105,8 @@ volatile int smp_tlb_wait; struct mtx smp_tlb_mtx; +extern inthand_t IDTVEC(fast_syscall), IDTVEC(fast_syscall32); + /* * Local data and functions. */ @@ -307,23 +310,59 @@ void init_secondary(void) { - int gsel_tss; - int myid; + int cpu, gsel_tss; + u_int64_t msr; +#if 1 + int x; +#endif u_int64_t cr0; struct pcpu *pc; - /* bootAP is set in start_ap() to our ID. */ - myid = bootAP; + /* Set by the startup code for us to use */ + cpu = bootAP; + + /* Init tss */ + common_tss[cpu] = common_tss[0]; + common_tss[cpu].tss_rsp0 = 0; /* not used until after switch */ + + gdt_segs[GPROC0_SEL].ssd_base = (long) &common_tss[cpu]; + +#if 1 + for (x = 0; x < NGDT; x++) + if (x != GPROC0_SEL && x != (GPROC0_SEL + 1)) + ssdtosd(&gdt_segs[x], &gdt[cpu * NGDT + x]); +#endif + ssdtosyssd(&gdt_segs[GPROC0_SEL], + (struct system_segment_descriptor *)&gdt[cpu * NGDT + GPROC0_SEL]); + +#if 1 + r_gdt.rd_limit = NGDT * sizeof(gdt[0]) - 1; + r_gdt.rd_base = (long) &gdt[cpu * NGDT]; +#endif + lgdt(&r_gdt); /* does magic intra-segment return */ - pc = &__pcpu[myid]; + /* Get per-cpu data */ + pc = &__pcpu[cpu]; + + /* prime data page for it to use */ + pcpu_init(pc, cpu, sizeof(struct pcpu)); + pc->pc_apic_id = cpu_apic_ids[cpu]; + pc->pc_prvspace = pc; + pc->pc_curthread = 0; + pc->pc_tssp = &common_tss[cpu]; + pc->pc_rsp0 = 0; wrmsr(MSR_FSBASE, 0); /* User value */ wrmsr(MSR_GSBASE, (u_int64_t)pc); - wrmsr(MSR_KGSBASE, 0); /* User value while we're in the kernel */ + wrmsr(MSR_KGSBASE, (u_int64_t)pc); /* User value while we're in the kernel */ lidt(&r_idt); +#if 1 + /* Every 'ltr' changes the type from SDT_SYSTSS to SDT_SYSBSY */ + ((struct system_segment_descriptor *)&gdt[cpu * NGDT + GPROC0_SEL])->sd_type = SDT_SYSTSS; +#endif gsel_tss = GSEL(GPROC0_SEL, SEL_KPL); ltr(gsel_tss); @@ -337,6 +376,16 @@ cr0 &= ~(CR0_CD | CR0_NW | CR0_EM); load_cr0(cr0); + /* Set up the fast syscall stuff */ + msr = rdmsr(MSR_EFER) | EFER_SCE; + wrmsr(MSR_EFER, msr); + wrmsr(MSR_LSTAR, (u_int64_t)IDTVEC(fast_syscall)); + wrmsr(MSR_CSTAR, (u_int64_t)IDTVEC(fast_syscall32)); + msr = ((u_int64_t)GSEL(GCODE_SEL, SEL_KPL) << 32) | + ((u_int64_t)GSEL(GUCODE32_SEL, SEL_UPL) << 48); + wrmsr(MSR_STAR, msr); + wrmsr(MSR_SF_MASK, PSL_NT|PSL_T|PSL_I|PSL_C|PSL_D); + /* Disable local apic just to be sure. */ lapic_disable(); @@ -453,8 +502,7 @@ { u_char mpbiosreason; u_int32_t mpbioswarmvec; - struct pcpu *pc; - int x, apic_id, cpu, i; + int apic_id, cpu, i; u_int64_t *pt4, *pt3, *pt2; mtx_init(&ap_boot_mtx, "ap boot", NULL, MTX_SPIN); @@ -488,6 +536,12 @@ outb(CMOS_REG, BIOS_RESET); mpbiosreason = inb(CMOS_DATA); + /* setup a vector to our boot code */ + *((volatile u_short *) WARMBOOT_OFF) = WARMBOOT_TARGET; + *((volatile u_short *) WARMBOOT_SEG) = (boot_address >> 4); + outb(CMOS_REG, BIOS_RESET); + outb(CMOS_DATA, BIOS_WARM); /* 'warm-start' */ + /* start each AP */ cpu = 0; for (apic_id = 0; apic_id < MAXCPU; apic_id++) { @@ -499,40 +553,9 @@ /* save APIC ID for this logical ID */ cpu_apic_ids[cpu] = apic_id; - /* Get per-cpu data */ - pc = &__pcpu[cpu]; - /* allocate and set up an idle stack data page */ bootstacks[cpu] = (char *)kmem_alloc(kernel_map, KSTACK_PAGES * PAGE_SIZE); - /* Init tss */ - common_tss[cpu] = common_tss[0]; - common_tss[cpu].tss_rsp0 = 0; /* not used until after switch */ - - /* XXX not so fast there sonny! */ - gdt_segs[GPROC0_SEL].ssd_base = (long) &common_tss[cpu]; - - for (x = 0; x < NGDT; x++) - if (x != GPROC0_SEL && x != (GPROC0_SEL + 1)) - ssdtosd(&gdt_segs[x], &gdt[cpu * NGDT + x]); - ssdtosyssd(&gdt_segs[GPROC0_SEL], - (struct system_segment_descriptor *)&gdt[cpu * NGDT + GPROC0_SEL]); - - r_gdt.rd_limit = NGDT * sizeof(gdt[0]) - 1; - r_gdt.rd_base = (long) &gdt[cpu * NGDT]; - - /* prime data page for it to use */ - pcpu_init(pc, cpu, sizeof(struct pcpu)); - pc->pc_apic_id = apic_id; - pc->pc_prvspace = pc; - pc->pc_curthread = 0; - - /* setup a vector to our boot code */ - *((volatile u_short *) WARMBOOT_OFF) = WARMBOOT_TARGET; - *((volatile u_short *) WARMBOOT_SEG) = (boot_address >> 4); - outb(CMOS_REG, BIOS_RESET); - outb(CMOS_DATA, BIOS_WARM); /* 'warm-start' */ - bootSTK = (char *)bootstacks[cpu] + KSTACK_PAGES * PAGE_SIZE - 8; bootAP = cpu; @@ -631,10 +654,10 @@ DELAY(200); /* wait ~200uS */ /* Wait up to 5 seconds for it to start. */ - for (ms = 0; ms < 5000; ms++) { + for (ms = 0; ms < 50; ms++) { if (mp_naps > cpus) return 1; /* return SUCCESS */ - DELAY(1000); + DELAY(100000); } return 0; /* return FAILURE */ } @@ -806,7 +829,9 @@ { struct thread *td; +#if 0 CTR0(KTR_SMP, "forwarded_statclock"); +#endif td = curthread; td->td_intr_nesting_level++; if (profprocs != 0) @@ -820,12 +845,18 @@ forward_statclock(void) { int map; + static int foocnt; +#if 0 CTR0(KTR_SMP, "forward_statclock"); +#endif if (!smp_started || cold || panicstr) return; + foocnt++; + if ((foocnt % 100) != 0) + return; map = PCPU_GET(other_cpus) & ~(stopped_cpus|hlt_cpus_mask); if (map != 0) ipi_selected(map, IPI_STATCLOCK); @@ -843,7 +874,9 @@ { struct thread *td; +#if 0 CTR0(KTR_SMP, "forwarded_hardclock"); +#endif td = curthread; td->td_intr_nesting_level++; hardclock_process(&frame); @@ -854,12 +887,18 @@ forward_hardclock(void) { u_int map; + static int foocnt; +#if 0 CTR0(KTR_SMP, "forward_hardclock"); +#endif if (!smp_started || cold || panicstr) return; + foocnt++; + if ((foocnt % 100) != 0) + return; map = PCPU_GET(other_cpus) & ~(stopped_cpus|hlt_cpus_mask); if (map != 0) ipi_selected(map, IPI_HARDCLOCK); From owner-p4-projects@FreeBSD.ORG Sun Nov 16 13:42:55 2003 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id AD3F416A4D5; Sun, 16 Nov 2003 13:42:54 -0800 (PST) Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 1314416A4D9 for ; Sun, 16 Nov 2003 13:42:54 -0800 (PST) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id D0B5543FE9 for ; Sun, 16 Nov 2003 13:42:52 -0800 (PST) (envelope-from peter@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.12.9/8.12.9) with ESMTP id hAGLgqXJ022060 for ; Sun, 16 Nov 2003 13:42:52 -0800 (PST) (envelope-from peter@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.12.9/8.12.9/Submit) id hAGLgq3b022057 for perforce@freebsd.org; Sun, 16 Nov 2003 13:42:52 -0800 (PST) (envelope-from peter@freebsd.org) Date: Sun, 16 Nov 2003 13:42:52 -0800 (PST) Message-Id: <200311162142.hAGLgq3b022057@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to peter@freebsd.org using -f From: Peter Wemm To: Perforce Change Reviews Subject: PERFORCE change 42583 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 16 Nov 2003 21:42:55 -0000 http://perforce.freebsd.org/chv.cgi?CH=42583 Change 42583 by peter@peter_overcee on 2003/11/16 13:42:23 stop thrashing the runq stuff so I have a chance to read the traces for now. Affected files ... .. //depot/projects/hammer/sys/vm/vm_zeroidle.c#6 edit Differences ... ==== //depot/projects/hammer/sys/vm/vm_zeroidle.c#6 (text+ko) ==== @@ -154,10 +154,12 @@ if (vm_page_zero_check()) { pages += vm_page_zero_idle(); if (pages > idlezero_maxrun || sched_runnable()) { +#if 0 mtx_lock_spin(&sched_lock); td->td_proc->p_stats->p_ru.ru_nvcsw++; mi_switch(); mtx_unlock_spin(&sched_lock); +#endif pages = 0; } } else { From owner-p4-projects@FreeBSD.ORG Sun Nov 16 13:45:58 2003 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 8ADBE16A4D0; Sun, 16 Nov 2003 13:45:58 -0800 (PST) Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 646F616A4CE for ; Sun, 16 Nov 2003 13:45:58 -0800 (PST) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id 459C943F75 for ; Sun, 16 Nov 2003 13:45:57 -0800 (PST) (envelope-from peter@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.12.9/8.12.9) with ESMTP id hAGLjvXJ022236 for ; Sun, 16 Nov 2003 13:45:57 -0800 (PST) (envelope-from peter@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.12.9/8.12.9/Submit) id hAGLjuf8022233 for perforce@freebsd.org; Sun, 16 Nov 2003 13:45:56 -0800 (PST) (envelope-from peter@freebsd.org) Date: Sun, 16 Nov 2003 13:45:56 -0800 (PST) Message-Id: <200311162145.hAGLjuf8022233@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to peter@freebsd.org using -f From: Peter Wemm To: Perforce Change Reviews Subject: PERFORCE change 42584 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 16 Nov 2003 21:45:59 -0000 http://perforce.freebsd.org/chv.cgi?CH=42584 Change 42584 by peter@peter_overcee on 2003/11/16 13:44:59 if you're going to update the graffiti, at least use the right name Affected files ... .. //depot/projects/hammer/sys/amd64/amd64/mp_machdep.c#34 edit Differences ... ==== //depot/projects/hammer/sys/amd64/amd64/mp_machdep.c#34 (text+ko) ==== @@ -1,6 +1,6 @@ /*- * Copyright (c) 1996, by Steve Passe - * Copyright (c) 2003, by Steve Passe + * Copyright (c) 2003, by Peter Wemm * All rights reserved. * * Redistribution and use in source and binary forms, with or without From owner-p4-projects@FreeBSD.ORG Sun Nov 16 13:48:03 2003 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id BDA3D16A4D0; Sun, 16 Nov 2003 13:48:02 -0800 (PST) Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 7F9B716A4CE for ; Sun, 16 Nov 2003 13:48:02 -0800 (PST) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id AA69143FE0 for ; Sun, 16 Nov 2003 13:48:00 -0800 (PST) (envelope-from peter@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.12.9/8.12.9) with ESMTP id hAGLm0XJ022294 for ; Sun, 16 Nov 2003 13:48:00 -0800 (PST) (envelope-from peter@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.12.9/8.12.9/Submit) id hAGLlxJJ022287 for perforce@freebsd.org; Sun, 16 Nov 2003 13:47:59 -0800 (PST) (envelope-from peter@freebsd.org) Date: Sun, 16 Nov 2003 13:47:59 -0800 (PST) Message-Id: <200311162147.hAGLlxJJ022287@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to peter@freebsd.org using -f From: Peter Wemm To: Perforce Change Reviews Subject: PERFORCE change 42585 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 16 Nov 2003 21:48:03 -0000 http://perforce.freebsd.org/chv.cgi?CH=42585 Change 42585 by peter@peter_daintree on 2003/11/16 13:47:20 IFC @42573 Affected files ... .. //depot/projects/hammer/Makefile.inc1#33 integrate .. //depot/projects/hammer/bin/Makefile.inc#5 integrate .. //depot/projects/hammer/lib/libc/posix1e/mac_get.3#5 integrate .. //depot/projects/hammer/lib/libc/posix1e/mac_get.c#4 integrate .. //depot/projects/hammer/lib/libc/posix1e/mac_set.3#4 integrate .. //depot/projects/hammer/lib/libc/posix1e/mac_text.3#6 integrate .. //depot/projects/hammer/lib/libc/sys/statfs.2#3 integrate .. //depot/projects/hammer/lib/libpthread/thread/thr_spinlock.c#8 integrate .. //depot/projects/hammer/release/doc/en_US.ISO8859-1/relnotes/common/new.sgml#46 integrate .. //depot/projects/hammer/sbin/Makefile.inc#4 integrate .. //depot/projects/hammer/sbin/dump/main.c#10 integrate .. //depot/projects/hammer/sbin/fsck_ffs/setup.c#8 integrate .. //depot/projects/hammer/sbin/gpt/add.c#4 integrate .. //depot/projects/hammer/sbin/gpt/migrate.c#5 integrate .. //depot/projects/hammer/sbin/gpt/recover.c#4 integrate .. //depot/projects/hammer/sbin/newfs/mkfs.c#12 integrate .. //depot/projects/hammer/sbin/newfs/newfs.c#8 integrate .. //depot/projects/hammer/sbin/newfs/newfs.h#4 integrate .. //depot/projects/hammer/sbin/umount/umount.c#8 integrate .. //depot/projects/hammer/share/examples/cvsup/cvs-supfile#4 integrate .. //depot/projects/hammer/share/examples/cvsup/ports-supfile#4 integrate .. //depot/projects/hammer/share/examples/cvsup/refuse#6 integrate .. //depot/projects/hammer/share/examples/cvsup/refuse.README#6 integrate .. //depot/projects/hammer/share/man/man4/miibus.4#4 integrate .. //depot/projects/hammer/share/man/man4/uplcom.4#2 integrate .. //depot/projects/hammer/share/man/man7/build.7#5 integrate .. //depot/projects/hammer/sys/alpha/alpha/vm_machdep.c#10 integrate .. //depot/projects/hammer/sys/alpha/include/sf_buf.h#1 branch .. //depot/projects/hammer/sys/amd64/amd64/vm_machdep.c#17 integrate .. //depot/projects/hammer/sys/amd64/include/sf_buf.h#1 branch .. //depot/projects/hammer/sys/boot/i386/btx/btx/btx.s#3 integrate .. //depot/projects/hammer/sys/compat/linux/linux_misc.c#15 integrate .. //depot/projects/hammer/sys/conf/NOTES#31 integrate .. //depot/projects/hammer/sys/conf/kmod.mk#13 integrate .. //depot/projects/hammer/sys/conf/options#29 integrate .. //depot/projects/hammer/sys/dev/usb/ubsa.c#8 integrate .. //depot/projects/hammer/sys/dev/usb/ucom.c#8 integrate .. //depot/projects/hammer/sys/dev/usb/umct.c#4 integrate .. //depot/projects/hammer/sys/dev/usb/uplcom.c#7 integrate .. //depot/projects/hammer/sys/dev/usb/usbdevs#21 integrate .. //depot/projects/hammer/sys/dev/usb/usbdevs.h#20 integrate .. //depot/projects/hammer/sys/dev/usb/usbdevs_data.h#20 integrate .. //depot/projects/hammer/sys/dev/usb/uvscom.c#6 integrate .. //depot/projects/hammer/sys/i386/i386/vm_machdep.c#15 integrate .. //depot/projects/hammer/sys/i386/include/sf_buf.h#1 branch .. //depot/projects/hammer/sys/i386/isa/cy.c#6 integrate .. //depot/projects/hammer/sys/i386/linux/linux_dummy.c#4 integrate .. //depot/projects/hammer/sys/i386/linux/linux_proto.h#6 integrate .. //depot/projects/hammer/sys/i386/linux/linux_syscall.h#6 integrate .. //depot/projects/hammer/sys/i386/linux/linux_sysent.c#7 integrate .. //depot/projects/hammer/sys/i386/linux/syscalls.master#6 integrate .. //depot/projects/hammer/sys/ia64/ia64/vm_machdep.c#16 integrate .. //depot/projects/hammer/sys/ia64/include/sf_buf.h#1 branch .. //depot/projects/hammer/sys/kern/uipc_cow.c#9 integrate .. //depot/projects/hammer/sys/kern/uipc_socket.c#15 integrate .. //depot/projects/hammer/sys/kern/uipc_syscalls.c#12 integrate .. //depot/projects/hammer/sys/modules/uplcom/Makefile#2 integrate .. //depot/projects/hammer/sys/netinet/ip_fastfwd.c#3 integrate .. //depot/projects/hammer/sys/powerpc/include/sf_buf.h#1 branch .. //depot/projects/hammer/sys/powerpc/powerpc/vm_machdep.c#9 integrate .. //depot/projects/hammer/sys/security/mac/mac_internal.h#6 integrate .. //depot/projects/hammer/sys/security/mac/mac_net.c#5 integrate .. //depot/projects/hammer/sys/security/mac_stub/mac_stub.c#2 integrate .. //depot/projects/hammer/sys/security/mac_test/mac_test.c#15 integrate .. //depot/projects/hammer/sys/sparc64/include/sf_buf.h#1 branch .. //depot/projects/hammer/sys/sparc64/sparc64/vm_machdep.c#9 integrate .. //depot/projects/hammer/sys/sys/mac.h#14 integrate .. //depot/projects/hammer/sys/sys/param.h#23 integrate .. //depot/projects/hammer/sys/sys/sf_buf.h#1 branch .. //depot/projects/hammer/sys/sys/socketvar.h#10 integrate .. //depot/projects/hammer/sys/ufs/ffs/fs.h#4 integrate .. //depot/projects/hammer/usr.sbin/ancontrol/ancontrol.c#5 integrate Differences ... ==== //depot/projects/hammer/Makefile.inc1#33 (text+ko) ==== @@ -1,7 +1,8 @@ # -# $FreeBSD: src/Makefile.inc1,v 1.396 2003/11/12 17:09:12 harti Exp $ +# $FreeBSD: src/Makefile.inc1,v 1.397 2003/11/16 21:17:43 gordon Exp $ # # Make command line options: +# -DNO_DYNAMICROOT do not link /bin and /sbin dynamically # -DNO_KERBEROS Do not build Heimdal (Kerberos 5) # -DNO_RESCUE do not build rescue binaries # -DNOCLEANDIR run ${MAKE} clean, instead of ${MAKE} cleandir @@ -52,7 +53,7 @@ # When upgrading to a dynamically linked root, install the runtime # linker early into its new location before make(1) has a chance # to run the dynamically linked /bin/sh. -.if defined(WITH_DYNAMICROOT) && !defined(NOPIC) && \ +.if !defined(NO_DYNAMICROOT) && !defined(NOPIC) && \ (!defined(TARGET_ARCH) || ${TARGET_ARCH} == ${MACHINE_ARCH}) && \ !defined(DISTDIR) && \ (!defined(DESTDIR) || empty(DESTDIR) || ${DESTDIR} == "/") && \ ==== //depot/projects/hammer/bin/Makefile.inc#5 (text+ko) ==== @@ -1,9 +1,9 @@ # @(#)Makefile.inc 8.1 (Berkeley) 5/31/93 -# $FreeBSD: src/bin/Makefile.inc,v 1.18 2003/11/02 06:47:38 ru Exp $ +# $FreeBSD: src/bin/Makefile.inc,v 1.19 2003/11/16 04:57:28 gordon Exp $ BINDIR?= /bin WARNS?= 6 -.if !defined(WITH_DYNAMICROOT) +.if defined(NO_DYNAMICROOT) NOSHARED?= YES .endif ==== //depot/projects/hammer/lib/libc/posix1e/mac_get.3#5 (text+ko) ==== @@ -28,7 +28,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" $FreeBSD: src/lib/libc/posix1e/mac_get.3,v 1.7 2003/09/12 21:54:10 ru Exp $ +.\" $FreeBSD: src/lib/libc/posix1e/mac_get.3,v 1.8 2003/11/16 20:18:24 rwatson Exp $ .\" .Dd December 21, 2001 .Dt MAC_GET 3 @@ -47,39 +47,46 @@ .Ft int .Fn mac_get_fd "int fd" "mac_t label" .Ft int +.Fn mac_get_peer "int fd" "mac_t label" +.Ft int .Fn mac_get_pid "pid_t pid" "mac_t label" .Ft int .Fn mac_get_proc "mac_t label" .Sh DESCRIPTION The .Fn mac_get_file -and +system call returns the label associated with a file specified by +pathname. +.Pp +The .Fn mac_get_fd -functions fill in -.Fa label -(which must first be allocated by -.Xr mac_prepare 3 ) -with the MAC label associated with the file referenced by -.Fa path -or the file descriptor specified by -.Fa fd , -respectively. -Note that this function will fail on socket descriptors. -For information on -getting MAC labels on socket descriptors see -.Xr getsockopt 2 . +system call returns the label associated with an object referenced by +the specified file descriptor. +Note that in the case of a file system socket, the label returned will +be the socket label, which may be different from the label of the +on-disk node acting as a rendezvous for the socket. +The +.Fn mac_get_peer +system call returns the label associated with the remote endpoint of +a socket; the exact semantics of this call will depend on the protocol +domain, communications type, and endpoint; typically this label will +be cached when a connection-oriented protocol instance is first set up, +and is undefined for datagram protocols. .Pp The +.Fn mac_get_pid +and .Fn mac_get_proc -and -.Fn mac_get_pid -functions fill in -.Fa label -(which must first be allocated by -.Xr mac_prepare 3 ) -with the MAC label associated -with the requesting process -or the specified process, respectively. +system calls return the process label associated with an arbitrary +process id, or the current process. +.Pp +Label storage for use with these calls must first be allocated and +prepared using the +.Xr mac_prepare 3 +functions. +When an application is done using a label, the memory may be returned +using +.Xr mac_free 3 . .Sh ERRORS .Bl -tag -width Er .It Bq Er EACCES @@ -88,6 +95,9 @@ is not searchable, or MAC read access to the file is denied. +.It Bq Er EINVAL +The requested label operation is not valid for the object referenced by +.Fa fd . .It Bq Er ENAMETOOLONG The pathname pointed to by .Fa path ==== //depot/projects/hammer/lib/libc/posix1e/mac_get.c#4 (text+ko) ==== @@ -28,14 +28,12 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $FreeBSD: src/lib/libc/posix1e/mac_get.c,v 1.3 2003/02/16 17:29:10 nectar Exp $ + * $FreeBSD: src/lib/libc/posix1e/mac_get.c,v 1.4 2003/11/16 20:18:24 rwatson Exp $ */ #include #include - -#include -#include +#include extern int __mac_get_fd(int fd, struct mac *mac_p); extern int __mac_get_file(const char *path_p, struct mac *mac_p); @@ -64,6 +62,15 @@ return (__mac_get_link(path, label)); } + +int +mac_get_peer(int fd, struct mac *label) +{ + socklen_t len; + + len = sizeof(*label); + return (getsockopt(fd, SOL_SOCKET, SO_PEERLABEL, label, &len)); +} int mac_get_pid(pid_t pid, struct mac *label) { ==== //depot/projects/hammer/lib/libc/posix1e/mac_set.3#4 (text+ko) ==== @@ -28,7 +28,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" $FreeBSD: src/lib/libc/posix1e/mac_set.3,v 1.9 2003/08/22 18:01:03 rwatson Exp $ +.\" $FreeBSD: src/lib/libc/posix1e/mac_set.3,v 1.10 2003/11/16 20:21:21 rwatson Exp $ .\" .Dd January 14, 2003 .Dt MAC_SET 3 @@ -63,15 +63,15 @@ or to the file descriptor .Fa fd , respectively. -Note that this function will fail on socket descriptors. -For information on -setting MAC labels on socket descriptors see -.Xr setsockopt 2 . +Note that when a file descriptor references a socket, label operations +on the file descriptor act on the socket, not on the file that may +have been used as a rendezvous when binding the socket. The .Fn mac_set_link function is the same as .Fn mac_set_file , except that it does not follow symlinks. +.Pp The .Fn mac_set_proc function associates the MAC label @@ -99,7 +99,9 @@ The .Fa label argument -is not a valid MAC label. +is not a valid MAC label, or the object referenced by +.Fa fd +is not appropriate for label operations. .It Bq Er EOPNOTSUPP Setting MAC labels is not supported by the file referenced by ==== //depot/projects/hammer/lib/libc/posix1e/mac_text.3#6 (text+ko) ==== @@ -28,7 +28,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" $FreeBSD: src/lib/libc/posix1e/mac_text.3,v 1.9 2003/08/22 18:01:03 rwatson Exp $ +.\" $FreeBSD: src/lib/libc/posix1e/mac_text.3,v 1.10 2003/11/16 04:32:46 rwatson Exp $ .\" .Dd December 21, 2001 .Dt MAC_TEXT 3 @@ -54,7 +54,7 @@ and places it in .Fa *mac , which must later be freed with -.Xr mac_free 3 . +.Xr free 3 . .Pp The .Fn mac_to_text @@ -72,6 +72,19 @@ POSIX.1e does not define a format for text representations of MAC labels. +.Pp +POSIX.1e requires that text strings allocated using +.Fn mac_to_text +be freed using +.Xr mac_free 3 ; +in the +.Fx +implementation, they must be freed using +.Xr free 3 , +as +.Xr mac_free 3 +is used only to free memory used for type +.Dv mac_t . .Sh ERRORS .Bl -tag -width Er .It Bq Er ENOMEM @@ -79,8 +92,8 @@ to allocate internal storage. .El .Sh SEE ALSO +.Xr free 3 , .Xr mac 3 , -.Xr mac_free 3 , .Xr mac_get 3 , .Xr mac_is_present_np 3 , .Xr mac_prepare 3 , ==== //depot/projects/hammer/lib/libc/sys/statfs.2#3 (text+ko) ==== @@ -30,9 +30,9 @@ .\" SUCH DAMAGE. .\" .\" @(#)statfs.2 8.5 (Berkeley) 5/24/95 -.\" $FreeBSD: src/lib/libc/sys/statfs.2,v 1.21 2002/12/19 09:40:25 ru Exp $ +.\" $FreeBSD: src/lib/libc/sys/statfs.2,v 1.22 2003/11/16 04:08:16 tjr Exp $ .\" -.Dd May 24, 1995 +.Dd November 16, 2003 .Dt STATFS 2 .Os .Sh NAME @@ -66,33 +66,39 @@ typedef struct fsid { int32_t val[2]; } fsid_t; /* file system id type */ /* - * file system statistics + * filesystem statistics */ -#define MFSNAMELEN 16 /* length of fs type name, including null */ -#define MNAMELEN 90 /* length of buffer for returned name */ +#define MFSNAMELEN 16 /* length of type name including null */ +#define MNAMELEN 88 /* size of on/from name bufs */ +#define STATFS_VERSION 0x20030518 /* current version number */ struct statfs { -long f_bsize; /* fundamental file system block size */ -long f_iosize; /* optimal transfer block size */ -long f_blocks; /* total data blocks in file system */ -long f_bfree; /* free blocks in fs */ -long f_bavail; /* free blocks avail to non-superuser */ -long f_files; /* total file nodes in file system */ -long f_ffree; /* free file nodes in fs */ -fsid_t f_fsid; /* file system id */ -uid_t f_owner; /* user that mounted the file system */ -int f_type; /* type of file system */ -int f_flags; /* copy of mount flags */ -long f_syncwrites; /* count of sync writes since mount */ -long f_asyncwrites; /* count of async writes since mount */ -char f_fstypename[MFSNAMELEN];/* fs type name */ -char f_mntonname[MNAMELEN]; /* mount point */ -long f_syncreads; /* count of sync reads since mount */ -long f_asyncreads; /* count of async reads since mount */ -char f_mntfromname[MNAMELEN]; /* mounted file system */ +uint32_t f_version; /* structure version number */ +uint32_t f_type; /* type of filesystem */ +uint64_t f_flags; /* copy of mount exported flags */ +uint64_t f_bsize; /* filesystem fragment size */ +uint64_t f_iosize; /* optimal transfer block size */ +uint64_t f_blocks; /* total data blocks in filesystem */ +uint64_t f_bfree; /* free blocks in filesystem */ +int64_t f_bavail; /* free blocks avail to non-superuser */ +uint64_t f_files; /* total file nodes in filesystem */ +int64_t f_ffree; /* free nodes avail to non-superuser */ +uint64_t f_syncwrites; /* count of sync writes since mount */ +uint64_t f_asyncwrites; /* count of async writes since mount */ +uint64_t f_syncreads; /* count of sync reads since mount */ +uint64_t f_asyncreads; /* count of async reads since mount */ +uint64_t f_spare[10]; /* unused spare */ +uint32_t f_namemax; /* maximum filename length */ +uid_t f_owner; /* user that mounted the filesystem */ +fsid_t f_fsid; /* filesystem id */ +char f_charspare[80]; /* spare string space */ +char f_fstypename[MFSNAMELEN]; /* filesystem type name */ +char f_mntfromname[MNAMELEN]; /* mounted filesystem */ +char f_mntonname[MNAMELEN]; /* directory on which mounted */ }; .Ed +.Pp The flags that may be returned include: .Bl -tag -width MNT_SYNCHRONOUS .It Dv MNT_RDONLY @@ -108,6 +114,27 @@ All I/O to the file system is done synchronously. .It Dv MNT_ASYNC No file system I/O is done synchronously. +.It Dv MNT_SOFTDEP +Soft updates being done (see +.Xr ffs 7). +.It Dv MNT_SUIDDIR +Special handling of SUID bit on directories. +.It Dv MNT_UNION +Union with underlying filesystem. +.It Dv MNT_NOSYMFOLLOW +Symbolic links are not followed. +.It Dv MNT_NOCLUSTERR +Read clustering is disabled. +.It Dv MNT_NOCLUSTERW +Write clustering is disabled. +.\".It Dv MNT_JAILDEVFS +.\"XXX +.It Dv MNT_MULTILABEL +Mandatory Access Control (MAC) support for individual objects +(see +.Xr mac 4). +.It Dv MNT_ACLS +Access Control List (ACL) support enabled. .It Dv MNT_LOCAL The file system resides locally. .It Dv MNT_QUOTA @@ -116,6 +143,12 @@ Identifies the root file system. .It Dv MNT_EXRDONLY The file system is exported read-only. +.It Dv MNT_NOATIME +Updating of file access times is disabled. +.It Dv MNT_USER +The file system has been mounted by a user. +.\".It Dv MNT_IGNORE +.\"XXX .It Dv MNT_EXPORTED The file system is exported for both reading and writing. .It Dv MNT_DEFEXPORTED @@ -124,6 +157,8 @@ The file system maps all remote accesses to the anonymous user. .It Dv MNT_EXKERB The file system is exported with Kerberos uid mapping. +.It Dv MNT_EXPUBLIC +The file system is exported publicly (WebNFS). .El .Pp Fields that are undefined for a particular file system are set to -1. ==== //depot/projects/hammer/lib/libpthread/thread/thr_spinlock.c#8 (text+ko) ==== @@ -29,7 +29,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $FreeBSD: src/lib/libpthread/thread/thr_spinlock.c,v 1.18 2003/11/08 06:07:04 davidxu Exp $ + * $FreeBSD: src/lib/libpthread/thread/thr_spinlock.c,v 1.19 2003/11/16 15:01:26 deischen Exp $ * */ @@ -45,7 +45,7 @@ struct spinlock_extra { spinlock_t *owner; struct lock lock; - struct pthread *crit; + kse_critical_t crit; }; static void init_spinlock(spinlock_t *lck); @@ -64,11 +64,12 @@ _spinunlock(spinlock_t *lck) { struct spinlock_extra *extra; - struct pthread *curthr = _get_curthread(); + kse_critical_t crit; extra = (struct spinlock_extra *)lck->fname; - THR_ASSERT(extra->crit == curthr, "_spinunlock called without owned."); - THR_LOCK_RELEASE(curthr, &extra->lock); + crit = extra->crit; + KSE_LOCK_RELEASE(_get_curkse(), &extra->lock); + _kse_critical_leave(crit); } @@ -81,8 +82,8 @@ void _spinlock(spinlock_t *lck) { - struct spinlock_extra *extra; - struct pthread *curthr; + struct spinlock_extra *extra; + kse_critical_t crit; THR_ASSERT(__isthreaded != 0, "Spinlock called when not threaded."); THR_ASSERT(initialized != 0, "Spinlocks not initialized."); @@ -90,12 +91,12 @@ * Try to grab the lock and loop if another thread grabs * it before we do. */ - curthr = _get_curthread(); + crit = _kse_critical_enter(); if (lck->fname == NULL) init_spinlock(lck); extra = (struct spinlock_extra *)lck->fname; - THR_LOCK_ACQUIRE(curthr, &extra->lock); - extra->crit = curthr; + KSE_LOCK_ACQUIRE(_get_curkse(), &extra->lock); + extra->crit = crit; } /* @@ -117,15 +118,15 @@ static void init_spinlock(spinlock_t *lck) { - struct pthread *curthr = _get_curthread(); + struct kse *curkse = _get_curkse(); - THR_LOCK_ACQUIRE(curthr, &spinlock_static_lock); + KSE_LOCK_ACQUIRE(curkse, &spinlock_static_lock); if ((lck->fname == NULL) && (spinlock_count < MAX_SPINLOCKS)) { lck->fname = (char *)&extra[spinlock_count]; extra[spinlock_count].owner = lck; spinlock_count++; } - THR_LOCK_RELEASE(curthr, &spinlock_static_lock); + KSE_LOCK_RELEASE(curkse, &spinlock_static_lock); THR_ASSERT(lck->fname != NULL, "Exceeded max spinlocks"); } @@ -136,19 +137,19 @@ if (initialized != 0) { _lock_reinit(&spinlock_static_lock, LCK_ADAPTIVE, - _thr_lock_wait, _thr_lock_wakeup); + _kse_lock_wait, _kse_lock_wakeup); for (i = 0; i < spinlock_count; i++) { _lock_reinit(&extra[i].lock, LCK_ADAPTIVE, - _thr_lock_wait, _thr_lock_wakeup); + _kse_lock_wait, _kse_lock_wakeup); } spinlock_count = 0; } else { if (_lock_init(&spinlock_static_lock, LCK_ADAPTIVE, - _thr_lock_wait, _thr_lock_wakeup) != 0) + _kse_lock_wait, _kse_lock_wakeup) != 0) PANIC("Cannot initialize spinlock_static_lock"); for (i = 0; i < MAX_SPINLOCKS; i++) { if (_lock_init(&extra[i].lock, LCK_ADAPTIVE, - _thr_lock_wait, _thr_lock_wakeup) != 0) + _kse_lock_wait, _kse_lock_wakeup) != 0) PANIC("Cannot initialize spinlock extra"); } initialized = 1; ==== //depot/projects/hammer/release/doc/en_US.ISO8859-1/relnotes/common/new.sgml#46 (text+ko) ==== @@ -3,7 +3,7 @@ The FreeBSD Project - $FreeBSD: src/release/doc/en_US.ISO8859-1/relnotes/common/new.sgml,v 1.651 2003/11/15 02:19:46 bmah Exp $ + $FreeBSD: src/release/doc/en_US.ISO8859-1/relnotes/common/new.sgml,v 1.652 2003/11/16 20:34:46 bmah Exp $ 2000 @@ -691,15 +691,18 @@ &man.rescue.8;. - It is now possible to build /bin and - /sbin directories containing - dynamically-linked executables. This feature brings support for + Executables in /bin and + /sbin are now built using dynamic, rather + than static linking. This feature brings support for loadable PAM and NSS modules to base system utilities located in those directories. It also reduces the storage requirements for the root filesystem due to the use of shared libraries. This - feature can be enabled in a buildworld by + feature can be disabled in a buildworld by defining the Makefile variable - WITH_DYNAMICROOT. + WITHOUT_DYNAMICROOT. Note that + statically-linked, crunched executables are available in the + /rescue directory for use during system + repair and recovery operations. ==== //depot/projects/hammer/sbin/Makefile.inc#4 (text+ko) ==== @@ -1,9 +1,9 @@ # @(#)Makefile.inc 8.1 (Berkeley) 6/8/93 -# $FreeBSD: src/sbin/Makefile.inc,v 1.10 2003/11/02 06:47:39 ru Exp $ +# $FreeBSD: src/sbin/Makefile.inc,v 1.11 2003/11/16 04:57:28 gordon Exp $ BINDIR?= /sbin WARNS?= 2 -.if !defined(WITH_DYNAMICROOT) +.if defined(NO_DYNAMICROOT) NOSHARED?= YES .endif ==== //depot/projects/hammer/sbin/dump/main.c#10 (text+ko) ==== @@ -42,7 +42,7 @@ static char sccsid[] = "@(#)main.c 8.6 (Berkeley) 5/1/95"; #endif static const char rcsid[] = - "$FreeBSD: src/sbin/dump/main.c,v 1.54 2003/11/14 13:07:38 johan Exp $"; + "$FreeBSD: src/sbin/dump/main.c,v 1.55 2003/11/16 08:01:58 mckusick Exp $"; #endif /* not lint */ #include @@ -317,20 +317,16 @@ msg("WARNING: %s\n", "should use -L when dumping live filesystems!"); } else { - struct ufs_args args; - char snapname[BUFSIZ]; + char snapname[BUFSIZ], snapcmd[BUFSIZ]; - snprintf(snapname, sizeof snapname, "%s/.dump_snapshot", - mntpt); - args.fspec = snapname; - while (mount("ffs", mntpt, - mntflags | MNT_UPDATE | MNT_SNAPSHOT, - &args) < 0) { - if (errno == EEXIST && unlink(snapname) == 0) - continue; + snprintf(snapname, sizeof snapname, + "%s/.snap/dump_snapshot", mntpt); + snprintf(snapcmd, sizeof snapcmd, + "mksnap_ffs %s %s", mntpt, snapname); + unlink(snapname); + if (system(snapcmd) != 0) errx(X_STARTUP, "Cannot create %s: %s\n", snapname, strerror(errno)); - } if ((diskfd = open(snapname, O_RDONLY)) < 0) { unlink(snapname); errx(X_STARTUP, "Cannot open %s: %s\n", ==== //depot/projects/hammer/sbin/fsck_ffs/setup.c#8 (text+ko) ==== @@ -37,7 +37,7 @@ #endif /* not lint */ #endif #include -__FBSDID("$FreeBSD: src/sbin/fsck_ffs/setup.c,v 1.44 2003/08/01 11:31:19 ru Exp $"); +__FBSDID("$FreeBSD: src/sbin/fsck_ffs/setup.c,v 1.45 2003/11/16 07:10:55 wes Exp $"); #include #include @@ -288,6 +288,10 @@ */ static int sblock_try[] = SBLOCKSEARCH; +#define BAD_MAGIC_MSG \ +"The previous newfs operation on this volume did not complete.\n" \ +"You must complete newfs before mounting this volume.\n" + /* * Read in the super block and its summary info. */ @@ -301,6 +305,10 @@ super = bflag; if ((bread(fsreadfd, (char *)&sblock, super, (long)SBLOCKSIZE))) return (0); + if (sblock.fs_magic == FS_BAD2_MAGIC) { + fprintf(stderr, BAD_MAGIC_MSG); + exit(11); + } if (sblock.fs_magic != FS_UFS1_MAGIC && sblock.fs_magic != FS_UFS2_MAGIC) { fprintf(stderr, "%d is not a file system superblock\n", @@ -313,6 +321,10 @@ if ((bread(fsreadfd, (char *)&sblock, super, (long)SBLOCKSIZE))) return (0); + if (sblock.fs_magic == FS_BAD2_MAGIC) { + fprintf(stderr, BAD_MAGIC_MSG); + exit(11); + } if ((sblock.fs_magic == FS_UFS1_MAGIC || (sblock.fs_magic == FS_UFS2_MAGIC && sblock.fs_sblockloc == sblock_try[i])) && ==== //depot/projects/hammer/sbin/gpt/add.c#4 (text+ko) ==== @@ -23,7 +23,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * $FreeBSD: src/sbin/gpt/add.c,v 1.4 2002/11/30 22:51:46 marcel Exp $ + * $FreeBSD: src/sbin/gpt/add.c,v 1.5 2003/11/16 06:45:26 kensmith Exp $ */ #include @@ -65,13 +65,14 @@ gpt = map_find(MAP_TYPE_PRI_GPT_HDR); if (gpt == NULL) { - warnx("%s: error: device does not contain a GPT", device_name); + warnx("%s: error: no primary GPT header; run create or recover", + device_name); return; } tpg = map_find(MAP_TYPE_SEC_GPT_HDR); if (tpg == NULL) { - warnx("%s: error: no secundary table; run recover", + warnx("%s: error: no secondary GPT header; run recover", device_name); return; } ==== //depot/projects/hammer/sbin/gpt/migrate.c#5 (text+ko) ==== @@ -23,7 +23,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * $FreeBSD: src/sbin/gpt/migrate.c,v 1.5 2002/12/02 01:42:03 marcel Exp $ + * $FreeBSD: src/sbin/gpt/migrate.c,v 1.6 2003/11/16 06:43:25 kensmith Exp $ */ #include @@ -41,6 +41,17 @@ #include "map.h" #include "gpt.h" +/* + * Allow compilation on platforms that do not have a BSD label. + * The values are valid for amd64, i386 and ia64 disklabels. + */ +#ifndef LABELOFFSET +#define LABELOFFSET 0 +#endif +#ifndef LABELSECTOR +#define LABELSECTOR 1 +#endif + int keep, slice; static void ==== //depot/projects/hammer/sbin/gpt/recover.c#4 (text+ko) ==== @@ -23,7 +23,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * $FreeBSD: src/sbin/gpt/recover.c,v 1.3 2002/11/10 20:22:25 marcel Exp $ + * $FreeBSD: src/sbin/gpt/recover.c,v 1.4 2003/11/16 06:45:26 kensmith Exp $ */ #include @@ -51,10 +51,97 @@ } static void -recover(int fd __unused) +recover(int fd) { + off_t last; + map_t *gpt, *tpg; + map_t *tbl, *lbt; + struct gpt_hdr *hdr; + + if (map_find(MAP_TYPE_MBR) != NULL) { + warnx("%s: error: device contains a MBR", device_name); + return; + } + + gpt = map_find(MAP_TYPE_PRI_GPT_HDR); + tpg = map_find(MAP_TYPE_SEC_GPT_HDR); + tbl = map_find(MAP_TYPE_PRI_GPT_TBL); + lbt = map_find(MAP_TYPE_SEC_GPT_TBL); - /* TODO */ + if (gpt == NULL && tpg == NULL) { + warnx("%s: no primary or secondary GPT headers, can't recover", + device_name); + return; + } + if (tbl == NULL && lbt == NULL) { + warnx("%s: no primary or secondary GPT tables, can't recover", + device_name); + return; + } + + last = mediasz / secsz - 1LL; + + if (tbl != NULL && lbt == NULL) { + lbt = map_add(last - tbl->map_size, tbl->map_size, + MAP_TYPE_SEC_GPT_TBL, tbl->map_data); + if (lbt == NULL) { + warnx("%s: adding secondary GPT table failed", + device_name); + return; + } + gpt_write(fd, lbt); + warnx("%s: recovered secondary GPT table from primary", + device_name); + } else if (tbl == NULL && lbt != NULL) { + tbl = map_add(2LL, lbt->map_size, MAP_TYPE_PRI_GPT_TBL, + lbt->map_data); + if (tbl == NULL) { + warnx("%s: adding primary GPT table failed", + device_name); + return; + } + gpt_write(fd, tbl); + warnx("%s: recovered primary GPT table from secondary", + device_name); + } + + if (gpt != NULL && tpg == NULL) { + tpg = map_add(last, 1LL, MAP_TYPE_SEC_GPT_HDR, + calloc(1, secsz)); + if (tpg == NULL) { + warnx("%s: adding secondary GPT header failed", + device_name); + return; + } + memcpy(tpg->map_data, gpt->map_data, secsz); + hdr = tpg->map_data; + hdr->hdr_lba_self = tpg->map_start; + hdr->hdr_lba_alt = gpt->map_start; + hdr->hdr_lba_table = lbt->map_start; + hdr->hdr_crc_self = 0; + hdr->hdr_crc_self = crc32(hdr, hdr->hdr_size); + gpt_write(fd, tpg); + warnx("%s: recovered secondary GPT header from primary", + device_name); + } else if (gpt == NULL && tpg != NULL) { + gpt = map_add(1LL, 1LL, MAP_TYPE_PRI_GPT_HDR, + calloc(1, secsz)); + if (gpt == NULL) { + warnx("%s: adding primary GPT header failed", + device_name); + return; + } + memcpy(gpt->map_data, tpg->map_data, secsz); + hdr = gpt->map_data; + hdr->hdr_lba_self = gpt->map_start; + hdr->hdr_lba_alt = tpg->map_start; + hdr->hdr_lba_table = tbl->map_start; + hdr->hdr_crc_self = 0; + hdr->hdr_crc_self = crc32(hdr, hdr->hdr_size); + gpt_write(fd, gpt); + warnx("%s: recovered primary GPT header from secondary", + device_name); + } } int ==== //depot/projects/hammer/sbin/newfs/mkfs.c#12 (text+ko) ==== @@ -46,7 +46,7 @@ #endif /* not lint */ #endif #include -__FBSDID("$FreeBSD: src/sbin/newfs/mkfs.c,v 1.79 2003/11/04 07:34:32 mckusick Exp $"); +__FBSDID("$FreeBSD: src/sbin/newfs/mkfs.c,v 1.81 2003/11/16 07:17:30 wes Exp $"); #include #include @@ -259,7 +259,7 @@ sblock.fs_old_postblformat = 1; sblock.fs_old_nrpos = 1; } else { - sblock.fs_magic = FS_UFS2_MAGIC; + sblock.fs_magic = FS_BAD2_MAGIC; sblock.fs_sblockloc = SBLOCK_UFS2; sblock.fs_nindir = sblock.fs_bsize / sizeof(ufs2_daddr_t); sblock.fs_inopb = sblock.fs_bsize / sizeof(struct ufs2_dinode); @@ -449,6 +449,16 @@ chdummy, SBLOCKSIZE); } } + if (!Nflag) + sbwrite(&disk, 0); + if (Eflag == 1) { + printf("** Exiting on Eflag 1\n"); + exit(0); + } + if (Eflag == 2) + printf("** Leaving BAD MAGIC on Eflag 2\n"); + else + sblock.fs_magic = FS_UFS2_MAGIC; /* * Now build the cylinders group blocks and @@ -504,6 +514,10 @@ sblock.fs_old_cstotal.cs_nifree = sblock.fs_cstotal.cs_nifree; sblock.fs_old_cstotal.cs_nffree = sblock.fs_cstotal.cs_nffree; } + if (Eflag == 3) { + printf("** Exiting on Eflag 3\n"); + exit(0); + } if (!Nflag) sbwrite(&disk, 0); for (i = 0; i < sblock.fs_cssize; i += sblock.fs_bsize) ==== //depot/projects/hammer/sbin/newfs/newfs.c#8 (text+ko) ==== @@ -52,7 +52,7 @@ #endif /* not lint */ #endif #include -__FBSDID("$FreeBSD: src/sbin/newfs/newfs.c,v 1.73 2003/05/03 18:41:58 obrien Exp $"); +__FBSDID("$FreeBSD: src/sbin/newfs/newfs.c,v 1.74 2003/11/16 07:17:30 wes Exp $"); /* * newfs: friendly front end to mkfs @@ -119,6 +119,7 @@ int Oflag = 2; /* file system format (1 => UFS1, 2 => UFS2) */ int Rflag; /* regression test */ int Uflag; /* enable soft updates for file system */ +int Eflag = 0; /* exit in middle of newfs for testing */ quad_t fssize; /* file system size */ int sectorsize; /* bytes/sector */ int realsectorsize; /* bytes/sector in hardware */ @@ -156,8 +157,11 @@ off_t mediasize; while ((ch = getopt(argc, argv, - "L:NO:RS:T:Ua:b:c:d:e:f:g:h:i:m:o:s:")) != -1) + "EL:NO:RS:T:Ua:b:c:d:e:f:g:h:i:m:o:s:")) != -1) switch (ch) { + case 'E': + Eflag++; + break; case 'L': volumelabel = optarg; i = -1; ==== //depot/projects/hammer/sbin/newfs/newfs.h#4 (text+ko) ==== @@ -39,7 +39,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $FreeBSD: src/sbin/newfs/newfs.h,v 1.13 2003/02/14 21:05:35 mckusick Exp $ + * $FreeBSD: src/sbin/newfs/newfs.h,v 1.14 2003/11/16 07:17:30 wes Exp $ */ #include @@ -52,6 +52,7 @@ extern int Oflag; /* build UFS1 format file system */ extern int Rflag; /* regression test */ extern int Uflag; /* enable soft updates for file system */ +extern int Eflag; /* exit as if error, for testing */ extern quad_t fssize; /* file system size */ extern int sectorsize; /* bytes/sector */ extern int realsectorsize; /* bytes/sector in hardware*/ ==== //depot/projects/hammer/sbin/umount/umount.c#8 (text+ko) ==== @@ -42,7 +42,7 @@ static char sccsid[] = "@(#)umount.c 8.8 (Berkeley) 5/8/95"; #endif static const char rcsid[] = - "$FreeBSD: src/sbin/umount/umount.c,v 1.40 2003/10/29 17:44:36 iedowse Exp $"; + "$FreeBSD: src/sbin/umount/umount.c,v 1.41 2003/11/16 16:48:18 iedowse Exp $"; #endif /* not lint */ #include @@ -359,7 +359,10 @@ snprintf(fsidbuf, sizeof(fsidbuf), "FSID:%d:%d", sfs->f_fsid.val[0], sfs->f_fsid.val[1]); if (unmount(fsidbuf, fflag | MNT_BYFSID) != 0) { - warn("unmount of %s failed", sfs->f_mntonname); + /* XXX, non-root users get a zero fsid, so don't warn. */ + if (errno != ENOENT || sfs->f_fsid.val[0] != 0 || >>> TRUNCATED FOR MAIL (1000 lines) <<< From owner-p4-projects@FreeBSD.ORG Sun Nov 16 13:51:06 2003 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 46ACC16A4D0; Sun, 16 Nov 2003 13:51:06 -0800 (PST) Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 202AC16A4CE for ; Sun, 16 Nov 2003 13:51:06 -0800 (PST) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id 79DDA43FAF for ; Sun, 16 Nov 2003 13:51:05 -0800 (PST) (envelope-from peter@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.12.9/8.12.9) with ESMTP id hAGLp5XJ022575 for ; Sun, 16 Nov 2003 13:51:05 -0800 (PST) (envelope-from peter@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.12.9/8.12.9/Submit) id hAGLp4p9022572 for perforce@freebsd.org; Sun, 16 Nov 2003 13:51:04 -0800 (PST) (envelope-from peter@freebsd.org) Date: Sun, 16 Nov 2003 13:51:04 -0800 (PST) Message-Id: <200311162151.hAGLp4p9022572@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to peter@freebsd.org using -f From: Peter Wemm To: Perforce Change Reviews Subject: PERFORCE change 42586 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 16 Nov 2003 21:51:06 -0000 http://perforce.freebsd.org/chv.cgi?CH=42586 Change 42586 by peter@peter_daintree on 2003/11/16 13:50:17 integ -I -b smp_hammer Affected files ... .. //depot/projects/hammer/sys/amd64/amd64/mp_machdep.c#35 integrate Differences ... ==== //depot/projects/hammer/sys/amd64/amd64/mp_machdep.c#35 (text+ko) ==== @@ -25,7 +25,7 @@ */ #include -__FBSDID("$FreeBSD: src/sys/i386/i386/mp_machdep.c,v 1.224 2003/11/12 18:13:57 jhb Exp $"); +__FBSDID("$FreeBSD: src/sys/i386/i386/mp_machdep.c,v 1.225 2003/11/16 00:55:53 bde Exp $"); #include "opt_cpu.h" #include "opt_kstack_pages.h" From owner-p4-projects@FreeBSD.ORG Sun Nov 16 14:02:24 2003 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 200D016A4D0; Sun, 16 Nov 2003 14:02:24 -0800 (PST) Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id EF65516A4CE for ; Sun, 16 Nov 2003 14:02:23 -0800 (PST) Received: from canning.wemm.org (canning.wemm.org [192.203.228.65]) by mx1.FreeBSD.org (Postfix) with ESMTP id 316C843F85 for ; Sun, 16 Nov 2003 14:02:22 -0800 (PST) (envelope-from peter@wemm.org) Received: from wemm.org (localhost [127.0.0.1]) by canning.wemm.org (Postfix) with ESMTP id 1CEAB2A8EB for ; Sun, 16 Nov 2003 14:02:22 -0800 (PST) (envelope-from peter@wemm.org) X-Mailer: exmh version 2.6.3 04/04/2003 with nmh-1.0.4 To: Perforce Change Reviews In-Reply-To: <200311162142.hAGLgpWg022045@repoman.freebsd.org> Content-Transfer-Encoding: 8bit Date: Sun, 16 Nov 2003 14:02:22 -0800 From: Peter Wemm Message-Id: <20031116220222.1CEAB2A8EB@canning.wemm.org> Subject: Re: PERFORCE change 42581 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 16 Nov 2003 22:02:24 -0000 Peter Wemm wrote: > http://perforce.freebsd.org/chv.cgi?CH=42581 > > Change 42581 by peter@peter_overcee on 2003/11/16 13:41:58 > > checkpoint, with all its WIP in full glory. And with that, we make it to single user! OK boot -s Copyright (c) 1992-2003 The FreeBSD Project. Copyright (c) 1979, 1980, 1983, 1986, 1988, 1989, 1991, 1992, 1993, 1994 The Regents of the University of California. All rights reserved. FreeBSD 5.1-CURRENT #195: Sun Nov 16 13:57:49 PST 2003 peter@overcee.wemm.org:/home/peter/fbp4/hammer/sys/amd64/compile/HAMMER Preloaded elf kernel "/boot/kernel/kernel" at 0xffffffff80600000. ACPI APIC Table: Timecounter "i8254" frequency 1193182 Hz quality 0 CPU: AMD Opteron(tm) Processor 844 (1797.66-MHz K8-class CPU) Origin = "AuthenticAMD" Id = 0xf58 Stepping = 8 Features=0x78bfbff AMD Features=0xe0500000 real memory = 2147483648 (2048 MB) avail memory = 2035417088 (1941 MB) FreeBSD/SMP: Multiprocessor System Detected: 4 CPUs cpu0 (BSP): APIC ID: 0 cpu1 (AP): APIC ID: 1 cpu2 (AP): APIC ID: 2 cpu3 (AP): APIC ID: 3 ioapic0 irqs 0-23 on motherboard ioapic1 irqs 24-27 on motherboard ioapic2 irqs 28-31 on motherboard ioapic3 irqs 32-35 on motherboard ioapic4 irqs 36-39 on motherboard Pentium Pro MTRR support enabled acpi0: on motherboard acpi0: Power Button (fixed) acpi0: Sleep Button (fixed) Timecounter "ACPI-fast" frequency 3579545 Hz quality 1000 unknown: I/O range not supported unknown: I/O range not supported acpi_timer0: <24-bit timer at 3.579545MHz> port 0x8008-0x800b on acpi0 acpi_cpu0: on acpi0 acpi_cpu1: on acpi0 acpi_cpu2: on acpi0 acpi_cpu3: on acpi0 acpi_button0: on acpi0 pcib0: port 0x8080-0x80ff,0x8000-0x807f,0xcf8-0xcff iomem 0xd8000-0xdbfff on acpi0 pcib0: could not get PCI interrupt routing table for \_SB_.PCI0 - AE_NOT_FOUND pci0: on pcib0 pcib1: at device 6.0 on pci0 pci1: on pcib1 ohci0: mem 0xfa100000-0xfa100fff irq 19 at device 0.0 on pci1 usb0: OHCI version 1.0, legacy support usb0: SMM does not respond, resetting usb0: on ohci0 usb0: USB revision 1.0 uhub0: AMD OHCI root hub, class 9/0, rev 1.00/1.00, addr 1 uhub0: 3 ports with 3 removable, self powered ohci1: mem 0xfa101000-0xfa101fff irq 19 at device 0.1 on pci1 usb1: OHCI version 1.0, legacy support usb1: on ohci1 usb1: USB revision 1.0 uhub1: AMD OHCI root hub, class 9/0, rev 1.00/1.00, addr 1 uhub1: 3 ports with 3 removable, self powered ehci0: mem 0xfa104000-0xfa1040ff irq 19 at device 0.2 on pci1 ehci_pci_attach: companion usb0 ehci_pci_attach: companion usb1 usb2: EHCI version 1.0 usb2: companion controllers, 3 ports each: usb0 usb1 usb2: on ehci0 usb2: USB revision 2.0 uhub2: AMD EHCI root hub, class 9/0, rev 2.00/1.00, addr 1 uhub2: 6 ports with 6 removable, self powered pci1: at device 1.0 (no driver attached) fxp0: port 0x2000-0x203f mem 0xfa000000-0xfa0fffff,0xfa103000-0xfa103fff irq 17 at device 5.0 on pci1 fxp0: Ethernet address 00:d0:b7:21:31:94 miibus0: on fxp0 inphy0: on miibus0 inphy0: 10baseT, 10baseT-FDX, 100baseTX, 100baseTX-FDX, auto isab0: at device 7.0 on pci0 isa0: on isab0 atapci0: port 0x1020-0x102f at device 7.1 on pci0 ata0: at 0x1f0 irq 14 on atapci0 ata0: [MPSAFE] ata1: at 0x170 irq 15 on atapci0 ata1: [MPSAFE] pci0: at device 7.3 (no driver attached) pcib2: on acpi0 pci8: on pcib2 pcib3: at device 1.0 on pci8 pci9: on pcib3 pci8: at device 1.1 (no driver attached) pcib4: at device 2.0 on pci8 pci10: on pcib4 pcib5: at device 1.0 on pci10 pci11: on pcib5 pcib5: slot 0 INTA is routed to irq 29 pci11: at device 0.0 (no driver attached) pci8: at device 2.1 (no driver attached) pcib6: at device 3.0 on pci8 pcib6: could not get PCI interrupt routing table for \_SB_.PCI1.G1PA - AE_NOT_FOUND pci12: on pcib6 pci8: at device 3.1 (no driver attached) pcib7: at device 4.0 on pci8 pci13: on pcib7 pci8: at device 4.1 (no driver attached) atkbdc0: port 0x64,0x60 irq 1 on acpi0 atkbd0: irq 1 on atkbdc0 kbd0 at atkbd0 sio0: configured irq 4 not in bitmap of probed irqs 0 sio0: port may not be enabled sio0 port 0x3f8-0x3ff irq 4 on acpi0 sio0: type 16550A, console sio1: configured irq 3 not in bitmap of probed irqs 0 sio1: port may not be enabled sio1 port 0x2f8-0x2ff irq 3 on acpi0 sio1: type 16550A ppc0 port 0x778-0x77f,0x378-0x37f irq 7 drq 3 on acpi0 ppc0: SMC-like chipset (ECP/EPP/PS2/NIBBLE) in COMPATIBLE mode ppc0: FIFO with 16/16/9 bytes threshold ppbus0: on ppc0 lpt0: on ppbus0 lpt0: Interrupt-driven port fdc0: port 0x3f7,0x3f0-0x3f5 irq 6 drq 2 on acpi0 fdc0: FIFO enabled, 8 bytes threshold fd0: <1440-KB 3.5" drive> on fdc0 drive 0 orm0: