From owner-svn-src-head@freebsd.org Wed Sep 21 10:10:37 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id C7A08BE397C; Wed, 21 Sep 2016 10:10:37 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 84E78A0F; Wed, 21 Sep 2016 10:10:37 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u8LAAaof090203; Wed, 21 Sep 2016 10:10:36 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u8LAAahN090202; Wed, 21 Sep 2016 10:10:36 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201609211010.u8LAAahN090202@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Wed, 21 Sep 2016 10:10:36 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r306088 - head/sys/amd64/include X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 21 Sep 2016 10:10:37 -0000 Author: kib Date: Wed Sep 21 10:10:36 2016 New Revision: 306088 URL: https://svnweb.freebsd.org/changeset/base/306088 Log: Add amd64 functions to load/store GDT register, store IDT and TR registers. Note that lgdt() name is already used for function which, besides loading GDT, also reloads segment descriptors cache, thus new function is named bare_lgdt(). Sponsored by: The FreeBSD Foundation MFC after: 1 week Modified: head/sys/amd64/include/cpufunc.h Modified: head/sys/amd64/include/cpufunc.h ============================================================================== --- head/sys/amd64/include/cpufunc.h Wed Sep 21 10:05:51 2016 (r306087) +++ head/sys/amd64/include/cpufunc.h Wed Sep 21 10:10:36 2016 (r306088) @@ -645,12 +645,36 @@ load_gs(u_short sel) #endif static __inline void +bare_lgdt(struct region_descriptor *addr) +{ + __asm __volatile("lgdt (%0)" : : "r" (addr)); +} + +static __inline void +sgdt(struct region_descriptor *addr) +{ + char *loc; + + loc = (char *)addr; + __asm __volatile("sgdt %0" : "=m" (*loc) : : "memory"); +} + +static __inline void lidt(struct region_descriptor *addr) { __asm __volatile("lidt (%0)" : : "r" (addr)); } static __inline void +sidt(struct region_descriptor *addr) +{ + char *loc; + + loc = (char *)addr; + __asm __volatile("sidt %0" : "=m" (*loc) : : "memory"); +} + +static __inline void lldt(u_short sel) { __asm __volatile("lldt %0" : : "r" (sel)); @@ -662,6 +686,15 @@ ltr(u_short sel) __asm __volatile("ltr %0" : : "r" (sel)); } +static __inline uint32_t +read_tr(void) +{ + u_short sel; + + __asm __volatile("str %0" : "=r" (sel)); + return (sel); +} + static __inline uint64_t rdr0(void) {