From owner-svn-src-all@freebsd.org Wed Oct 5 22:02:38 2016 Return-Path: Delivered-To: svn-src-all@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 7397DAF7B6B; Wed, 5 Oct 2016 22:02:38 +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 4B03EE77; Wed, 5 Oct 2016 22:02:38 +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 u95M2bGe037900; Wed, 5 Oct 2016 22:02:37 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u95M2aVL037893; Wed, 5 Oct 2016 22:02:36 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201610052202.u95M2aVL037893@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Wed, 5 Oct 2016 22:02:36 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r306737 - in stable/11/sys: amd64/amd64 amd64/conf amd64/include conf modules modules/efirt X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 05 Oct 2016 22:02:38 -0000 Author: kib Date: Wed Oct 5 22:02:36 2016 New Revision: 306737 URL: https://svnweb.freebsd.org/changeset/base/306737 Log: MFC r306097: Add kernel interfaces to call EFI Runtime Services. MFC r306104: Fix build of the module outside the kernel tree. MFC r306209 (by imp): Change the efi_get_table interface to a void **. MFC r306351: Handle TLB shootdown IPI during the EFI runtime calls, on SandyBridges. Added: stable/11/sys/amd64/amd64/efirt.c (contents, props changed) - copied, changed from r306097, head/sys/amd64/amd64/efirt.c stable/11/sys/modules/efirt/ - copied from r306097, head/sys/modules/efirt/ Modified: stable/11/sys/amd64/conf/NOTES stable/11/sys/amd64/include/efi.h stable/11/sys/conf/files.amd64 stable/11/sys/conf/options.amd64 stable/11/sys/modules/Makefile stable/11/sys/modules/efirt/Makefile Directory Properties: stable/11/ (props changed) Copied and modified: stable/11/sys/amd64/amd64/efirt.c (from r306097, head/sys/amd64/amd64/efirt.c) ============================================================================== --- head/sys/amd64/amd64/efirt.c Wed Sep 21 11:31:58 2016 (r306097, copy source) +++ stable/11/sys/amd64/amd64/efirt.c Wed Oct 5 22:02:36 2016 (r306737) @@ -53,6 +53,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -301,6 +302,17 @@ efi_enter(void) PMAP_UNLOCK(curpmap); return (error); } + + /* + * IPI TLB shootdown handler invltlb_pcid_handler() reloads + * %cr3 from the curpmap->pm_cr3, which would disable runtime + * segments mappings. Block the handler's action by setting + * curpmap to impossible value. See also comment in + * pmap.c:pmap_activate_sw(). + */ + if (pmap_pcid_enabled && !invpcid_works) + PCPU_SET(curpmap, NULL); + load_cr3(VM_PAGE_TO_PHYS(efi_pml4_page) | (pmap_pcid_enabled ? curpmap->pm_pcids[PCPU_GET(cpuid)].pm_pcid : 0)); /* @@ -317,7 +329,9 @@ efi_leave(void) { pmap_t curpmap; - curpmap = PCPU_GET(curpmap); + curpmap = &curproc->p_vmspace->vm_pmap; + if (pmap_pcid_enabled && !invpcid_works) + PCPU_SET(curpmap, curpmap); load_cr3(curpmap->pm_cr3 | (pmap_pcid_enabled ? curpmap->pm_pcids[PCPU_GET(cpuid)].pm_pcid : 0)); if (!pmap_pcid_enabled) @@ -405,7 +419,7 @@ efi_uninit(void) } int -efi_get_table(struct uuid *uuid, void *ptr) +efi_get_table(struct uuid *uuid, void **ptr) { struct efi_cfgtbl *ct; u_long count; @@ -416,7 +430,7 @@ efi_get_table(struct uuid *uuid, void *p ct = efi_cfgtbl; while (count--) { if (!bcmp(&ct->ct_uuid, uuid, sizeof(*uuid))) { - ptr = (void *)PHYS_TO_DMAP(ct->ct_data); + *ptr = (void *)PHYS_TO_DMAP(ct->ct_data); return (0); } ct++; Modified: stable/11/sys/amd64/conf/NOTES ============================================================================== --- stable/11/sys/amd64/conf/NOTES Wed Oct 5 20:45:21 2016 (r306736) +++ stable/11/sys/amd64/conf/NOTES Wed Oct 5 22:02:36 2016 (r306737) @@ -599,6 +599,9 @@ options ENABLE_ALART # Control alarm o # options NKPT=31 +# EFI Runtime Services support (not functional yet). +options EFIRT + ##################################################################### # ABI Emulation Modified: stable/11/sys/amd64/include/efi.h ============================================================================== --- stable/11/sys/amd64/include/efi.h Wed Oct 5 20:45:21 2016 (r306736) +++ stable/11/sys/amd64/include/efi.h Wed Oct 5 22:02:36 2016 (r306737) @@ -39,4 +39,21 @@ */ #define EFIABI_ATTR __attribute__((ms_abi)) +#ifdef _KERNEL +struct uuid; +struct efi_tm; + +int efi_get_table(struct uuid *uuid, void **ptr); +int efi_get_time(struct efi_tm *tm); +int efi_get_time_locked(struct efi_tm *tm); +int efi_reset_system(void); +int efi_set_time(struct efi_tm *tm); +int efi_set_time_locked(struct efi_tm *tm); +int efi_var_get(uint16_t *name, struct uuid *vendor, uint32_t *attrib, + size_t *datasize, void *data); +int efi_var_nextname(size_t *namesize, uint16_t *name, struct uuid *vendor); +int efi_var_set(uint16_t *name, struct uuid *vendor, uint32_t attrib, + size_t datasize, void *data); +#endif + #endif /* __AMD64_INCLUDE_EFI_H_ */ Modified: stable/11/sys/conf/files.amd64 ============================================================================== --- stable/11/sys/conf/files.amd64 Wed Oct 5 20:45:21 2016 (r306736) +++ stable/11/sys/conf/files.amd64 Wed Oct 5 22:02:36 2016 (r306737) @@ -110,6 +110,7 @@ amd64/amd64/cpu_switch.S standard amd64/amd64/db_disasm.c optional ddb amd64/amd64/db_interface.c optional ddb amd64/amd64/db_trace.c optional ddb +amd64/amd64/efirt.c optional efirt amd64/amd64/elf_machdep.c standard amd64/amd64/exception.S standard amd64/amd64/fpu.c standard Modified: stable/11/sys/conf/options.amd64 ============================================================================== --- stable/11/sys/conf/options.amd64 Wed Oct 5 20:45:21 2016 (r306736) +++ stable/11/sys/conf/options.amd64 Wed Oct 5 22:02:36 2016 (r306737) @@ -65,3 +65,6 @@ XENHVM opt_global.h # options for the Intel C600 SAS driver (isci) ISCI_LOGGING opt_isci.h + +# EFI Runtime services support +EFIRT opt_efirt.h Modified: stable/11/sys/modules/Makefile ============================================================================== --- stable/11/sys/modules/Makefile Wed Oct 5 20:45:21 2016 (r306736) +++ stable/11/sys/modules/Makefile Wed Oct 5 22:02:36 2016 (r306737) @@ -102,6 +102,7 @@ SUBDIR= \ ${_drm2} \ dummynet \ ${_ed} \ + ${_efirt} \ ${_elink} \ ${_em} \ en \ @@ -666,6 +667,7 @@ _x86bios= x86bios .endif .if ${MACHINE_CPUARCH} == "amd64" +_efirt= efirt _ioat= ioat _ixl= ixl _ixlv= ixlv Modified: stable/11/sys/modules/efirt/Makefile ============================================================================== --- head/sys/modules/efirt/Makefile Wed Sep 21 11:31:58 2016 (r306097) +++ stable/11/sys/modules/efirt/Makefile Wed Oct 5 22:02:36 2016 (r306737) @@ -4,5 +4,6 @@ KMOD= efirt SRCS= efirt.c +SRCS+= device_if.h bus_if.h .include