On Wed, Sep 04, 2013 at 07:56:45AM -0400, John Baldwin wrote: > On Wednesday, September 04, 2013 12:25:35 am Konstantin Belousov wrote: > > On Tue, Sep 03, 2013 at 09:21:47PM +0000, John Baldwin wrote: > > > Author: jhb > > > Date: Tue Sep 3 21:21:47 2013 > > > New Revision: 255192 > > > URL: http://svnweb.freebsd.org/changeset/base/255192 > > > > > > Log: > > > Add support for the 'invpcid' instruction to binutils and DDB's > > > disassembler on amd64. > > > > > > MFC after: 1 month > > > > Nice, thank you. > > > > Do you agree with me that it is premature to start using the mnemonics > > in the kernel source until the changes are merged into stable/9 at least ? > > That is fine. Can you test that using them directly works fine with GCC? > I know clang already supported this instruction.
Hmm, tried make buildkernel CC=gcc for the world (and builworld area) built after your commit. I get gcc -c -x assembler-with-cpp -DLOCORE -O2 -frename-registers -pipe -fno-strict-a liasing -std=c99 -g -Wall -Wredundant-decls -Wnested-externs -Wstrict-prototype s -Wmissing-prototypes -Wpointer-arith -Winline -Wcast-qual -Wundef -Wno-point er-sign -fformat-extensions -Wmissing-include-dirs -fdiagnostics-show-option -nostdinc -I. -I/usr/home/kostik/work/build/bsd/DEV/src/sys -I/usr/home/kostik/ work/build/bsd/DEV/src/sys/contrib/altq -I/usr/home/kostik/work/build/bsd/DEV/sr c/sys/contrib/libfdt -D_KERNEL -DHAVE_KERNEL_OPTION_HEADERS -include opt_global. h -fno-common -finline-limit=8000 --param inline-unit-growth=100 --param large-f unction-growth=1000 -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -mcmod el=kernel -mno-red-zone -mno-mmx -mno-sse -msoft-float -fno-asynchronous-unwind -tables -ffreestanding -fstack-protector -Werror /usr/home/kostik/work/build/bsd/DEV/src/sys/amd64/amd64/exception.S /usr/home/kostik/work/build/bsd/DEV/src/sys/amd64/amd64/apic_vector.S: Assembler messages: /usr/home/kostik/work/build/bsd/DEV/src/sys/amd64/amd64/apic_vector.S:224: Error: no such instruction: `invpcid (%rdx),%rax' /usr/home/kostik/work/build/bsd/DEV/src/sys/amd64/amd64/apic_vector.S:312: Error: no such instruction: `invpcid (%rdx),%rax' /usr/home/kostik/work/build/bsd/DEV/src/sys/amd64/amd64/apic_vector.S:409: Error: no such instruction: `invpcid (%rdx),%rax' *** Error code 1 On the other hand, with the target machine, I successfully did the config/make style of the kernel build and verified that the assembled byte sequences for the invpcid are the same as manually assembled. I have no haswell machine to test this at runtime, but I believe that what was done is enough. diff --git a/sys/amd64/amd64/apic_vector.S b/sys/amd64/amd64/apic_vector.S index d002b4d..0e00549 100644 --- a/sys/amd64/amd64/apic_vector.S +++ b/sys/amd64/amd64/apic_vector.S @@ -221,8 +221,7 @@ IDTVEC(invltlb_pcid) je 1f /* Use invpcid if available. */ movl $1,%eax /* INVPCID_CTX */ - /* invpcid (%rdx),%rax */ - .byte 0x66,0x0f,0x38,0x82,0x02 + invpcid (%rdx),%rax jmp invltlb_ret_clear_pm_save 1: /* Otherwise reload %cr3 twice. */ @@ -309,8 +308,7 @@ IDTVEC(invlpg_pcid) */ 2: xorl %eax,%eax -/* invpcid (%rdx),%rax */ - .byte 0x66,0x0f,0x38,0x82,0x02 + invpcid (%rdx),%rax jmp invltlb_ret_rdx /* @@ -406,8 +404,7 @@ invlrng_invpcid: subq %rax,%rcx shrq $PAGE_SHIFT,%rcx 1: -// invpcid (%rdx),%rax - .byte 0x66,0x0f,0x38,0x82,0x02 + invpcid (%rdx),%rax addq $PAGE_SIZE,8(%rsp) dec %rcx jne 1b diff --git a/sys/amd64/include/cpufunc.h b/sys/amd64/include/cpufunc.h index 3d381c6..f1b8209 100644 --- a/sys/amd64/include/cpufunc.h +++ b/sys/amd64/include/cpufunc.h @@ -487,9 +487,8 @@ static __inline void invpcid(struct invpcid_descr *d, int type) { - /* invpcid (%rdx),%rax */ - __asm __volatile(".byte 0x66,0x0f,0x38,0x82,0x02" - : : "d" (d), "a" ((u_long)type) : "memory"); + __asm __volatile("invpcid (%0),%1" + : : "r" (d), "r" ((u_long)type) : "memory"); } static __inline u_short
pgpts4ZrPx0mO.pgp
Description: PGP signature