From owner-freebsd-hackers@FreeBSD.ORG Wed Sep 23 19:08:54 2009 Return-Path: Delivered-To: hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id BD09B106568F; Wed, 23 Sep 2009 19:08:54 +0000 (UTC) (envelope-from nate@thatsmathematics.com) Received: from euclid.ucsd.edu (euclid.ucsd.edu [132.239.145.52]) by mx1.freebsd.org (Postfix) with ESMTP id 982C98FC31; Wed, 23 Sep 2009 19:08:54 +0000 (UTC) Received: from zeno.ucsd.edu (zeno.ucsd.edu [132.239.145.22]) by euclid.ucsd.edu (8.11.7p3+Sun/8.11.7) with ESMTP id n8NJ8ro08447; Wed, 23 Sep 2009 12:08:53 -0700 (PDT) Received: from localhost (neldredg@localhost) by zeno.ucsd.edu (8.11.7p3+Sun/8.11.7) with ESMTP id n8NJ8rD02023; Wed, 23 Sep 2009 12:08:53 -0700 (PDT) X-Authentication-Warning: zeno.ucsd.edu: neldredg owned process doing -bs Date: Wed, 23 Sep 2009 12:08:52 -0700 (PDT) From: Nate Eldredge X-X-Sender: neldredg@zeno.ucsd.edu To: John Baldwin In-Reply-To: <200909231436.29466.jhb@freebsd.org> Message-ID: References: <200909231554.n8NFsYwT078965@fire.js.berklix.net> <200909231209.08346.jhb@freebsd.org> <4ABA5937.9000406@elischer.org> <200909231436.29466.jhb@freebsd.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Cc: Rui Paulo , Alexey Shuvaev , "Julian H. Stacey" , hackers@freebsd.org, Julian Elischer Subject: Re: genuine cpu I386_CPU kernel support X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 23 Sep 2009 19:08:54 -0000 On Wed, 23 Sep 2009, John Baldwin wrote: > On Wednesday 23 September 2009 1:21:59 pm Julian Elischer wrote: >> John Baldwin wrote: >>> Other things added since then assume at least a 486. Not having cmpxchg is a >>> bit of a killer. >> >> I think a 386 can assume non-SMP in which case that can be simulated >> just fine :-) >> it also simplifies a lot of the other breakages.. >> >> #if (CPU == 80386) && defined(SMP) >> #error "can't have smp on a 386" >> #endif > > No, it actually does not. The in-kernel version of cmpset for 386 was to > disable interrupts while doing a cmp and jmp around a mov (even 386's have > preemption, so you do have to disable interrupts). You can't do that in > userland (cli is a privileged instruction), which probably mandates doing a > cmpxchg emulator in the kernel for userland code. That and disabling > interrupts is actually far less efficient than spl() for a UP 80386 machine. > I suspect newer kernels will run slower on an 80386 than 4.x. Another issue that I know affected Linux is that the 386 would allow kernel code (CPL 0) to write to a page that was marked read-only. The 486 and later would generate a page fault. Linux takes advantage of the 486 behavior to avoid having to do explicit access checks when copying to user space, though AFAIK it checks the CPU at boot time to decide if this can be done. I haven't checked whether FreeBSD uses this feature, but it would be another thing to watch out for. -- Nate Eldredge nate@thatsmathematics.com