From owner-freebsd-hackers@FreeBSD.ORG Tue Aug 22 10:36:42 2006 Return-Path: X-Original-To: freebsd-hackers@freebsd.org Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 77F9416A4E0 for ; Tue, 22 Aug 2006 10:36:42 +0000 (UTC) (envelope-from asmrookie@gmail.com) Received: from wx-out-0506.google.com (wx-out-0506.google.com [66.249.82.236]) by mx1.FreeBSD.org (Postfix) with ESMTP id A2DA943D45 for ; Tue, 22 Aug 2006 10:36:41 +0000 (GMT) (envelope-from asmrookie@gmail.com) Received: by wx-out-0506.google.com with SMTP id i27so1881440wxd for ; Tue, 22 Aug 2006 03:36:41 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:sender:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references:x-google-sender-auth; b=Z1HoXblaktRHC836xGvFfjn5E0wCxU0IbulxLybxco5QDBi7kI/NhSocg5G8Ee6Y9C/VjKwIF72bIHRE2nT2JwP4BytqEtqi7Ms+/ehg8FZj0Lke1Op9Nkj3InuakvKbshNbNoeM9oupSRvJVUpvEHqTW2ds/1eLc9q1MbiTeJE= Received: by 10.70.42.15 with SMTP id p15mr8514137wxp; Tue, 22 Aug 2006 03:36:40 -0700 (PDT) Received: by 10.70.11.4 with HTTP; Tue, 22 Aug 2006 03:36:40 -0700 (PDT) Message-ID: <3bbf2fe10608220336s24968560i8565040a2d7eb9c7@mail.gmail.com> Date: Tue, 22 Aug 2006 12:36:40 +0200 From: "Attilio Rao" Sender: asmrookie@gmail.com To: "Stanislav Sedov" In-Reply-To: <20060814194729.436fc453@localhost> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <20060814124658.1d416cbe@localhost> <200608140932.57875.jhb@freebsd.org> <20060814194729.436fc453@localhost> X-Google-Sender-Auth: 142fdb69eee2d58e Cc: freebsd-hackers@freebsd.org Subject: Re: exception handling in kernel code 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: Tue, 22 Aug 2006 10:36:42 -0000 2006/8/14, Stanislav Sedov : > On Mon, 14 Aug 2006 09:32:57 -0400 > John Baldwin mentioned: > > > > You can make use of pcb_onfault to recover from a page fault, but that's > > about it. Kernel code is expected to not generate exceptions. :) > > > > Thanks a lot! I'll try it. > > To clarify: > > I've implemented driver to allow user-level code to read MSRs (Model > specific registers) (like linux's /dev/cpu/msr). It's required for > some programs like x86info. > > As long as not all MSRs documented and reading/writing unexistent MSR > leads to GP fault, I need to recover in that case. Mmm, I think that a better approach would be refering to different MSRs tables for pentium, p6 and Pentium 4 (if I remind correctly they are which show differences). It is more extensible, portable and possibly cleaner (I.E: you could port automatically to openbsd/netbsd, adding new table and make minimum modifies, etc.) You could find differences in the tables in the Intel manual (vol. 3) and for undocumented MSRs (if I remind correctly) you could find informations here: http://www.x86.org/articles/p5msr/pentiummsrs.htm or similar sites. Attilio -- Peace can only be achieved by understanding - A. Einstein