From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.2 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_SANE_2 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 91DAFCA9ECF for ; Fri, 1 Nov 2019 14:28:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 6FA1821835 for ; Fri, 1 Nov 2019 14:28:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727321AbfKAO17 (ORCPT ); Fri, 1 Nov 2019 10:27:59 -0400 Received: from mga05.intel.com ([192.55.52.43]:9673 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726658AbfKAO17 (ORCPT ); Fri, 1 Nov 2019 10:27:59 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 01 Nov 2019 07:27:58 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.68,255,1569308400"; d="scan'208";a="375578378" Received: from yyu32-desk1.sc.intel.com ([10.144.153.205]) by orsmga005.jf.intel.com with ESMTP; 01 Nov 2019 07:27:57 -0700 Message-ID: <221c36d6646ea9f88d208dc02494872a34d8b61f.camel@intel.com> Subject: Re: [PATCH v7 27/27] x86/cet/shstk: Add Shadow Stack instructions to opcode map From: Yu-cheng Yu To: Adrian Hunter , x86@kernel.org, "H. Peter Anvin" , Thomas Gleixner , Ingo Molnar , linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, linux-mm@kvack.org, linux-arch@vger.kernel.org, linux-api@vger.kernel.org, Arnd Bergmann , Andy Lutomirski , Balbir Singh , Borislav Petkov , Cyrill Gorcunov , Dave Hansen , Eugene Syromiatnikov , Florian Weimer , "H.J. Lu" , Jann Horn , Jonathan Corbet , Kees Cook , Mike Kravetz , Nadav Amit , Oleg Nesterov , Pavel Machek , Peter Zijlstra , Randy Dunlap , "Ravi V. Shankar" , Vedvyas Shanbhogue , Dave Martin Date: Fri, 01 Nov 2019 07:17:45 -0700 In-Reply-To: <93e915b9-975d-9876-8f89-8b6f2bc4586e@intel.com> References: <20190606200646.3951-1-yu-cheng.yu@intel.com> <20190606200646.3951-28-yu-cheng.yu@intel.com> <93e915b9-975d-9876-8f89-8b6f2bc4586e@intel.com> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.28.1-2 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 2019-11-01 at 16:03 +0200, Adrian Hunter wrote: > On 6/06/19 11:06 PM, Yu-cheng Yu wrote: > > Add the following shadow stack management instructions. > > > > INCSSP: > > Increment shadow stack pointer by the steps specified. > > > > RDSSP: > > Read SSP register into a GPR. > > > > SAVEPREVSSP: > > Use "prev ssp" token at top of current shadow stack to > > create a "restore token" on previous shadow stack. > > > > RSTORSSP: > > Restore from a "restore token" pointed by a GPR to SSP. > > > > WRSS: > > Write to kernel-mode shadow stack (kernel-mode instruction). > > > > WRUSS: > > Write to user-mode shadow stack (kernel-mode instruction). > > > > SETSSBSY: > > Verify the "supervisor token" pointed by IA32_PL0_SSP MSR, > > if valid, set the token to busy, and set SSP to the value > > of IA32_PL0_SSP MSR. > > > > CLRSSBSY: > > Verify the "supervisor token" pointed by a GPR, if valid, > > clear the busy bit from the token. > > Does the notrack prefix also need to be catered for somehow? Yes, I will fix it. > > > > > Signed-off-by: Yu-cheng Yu > > --- > > arch/x86/lib/x86-opcode-map.txt | 26 +++++++++++++------ > > tools/objtool/arch/x86/lib/x86-opcode-map.txt | 26 +++++++++++++------ > > 2 files changed, 36 insertions(+), 16 deletions(-) > > > > diff --git a/arch/x86/lib/x86-opcode-map.txt b/arch/x86/lib/x86-opcode-map.txt > > index e0b85930dd77..c5e825d44766 100644 > > --- a/arch/x86/lib/x86-opcode-map.txt > > +++ b/arch/x86/lib/x86-opcode-map.txt > > @@ -366,7 +366,7 @@ AVXcode: 1 > > 1b: BNDCN Gv,Ev (F2) | BNDMOV Ev,Gv (66) | BNDMK Gv,Ev (F3) | BNDSTX Ev,Gv > > 1c: > > 1d: > > -1e: > > +1e: RDSSP Rd (F3),REX.W > > 1f: NOP Ev > > # 0x0f 0x20-0x2f > > 20: MOV Rd,Cd > > @@ -610,7 +610,17 @@ fe: paddd Pq,Qq | vpaddd Vx,Hx,Wx (66),(v1) > > ff: UD0 > > EndTable > > > > -Table: 3-byte opcode 1 (0x0f 0x38) > > +Table: 3-byte opcode 1 (0x0f 0x01) > > +Referrer: > > +AVXcode: > > +# Skip 0x00-0xe7 > > +e8: SETSSBSY (f3) > > +e9: > > +ea: SAVEPREVSSP (f3) > > +# Skip 0xeb-0xff > > +EndTable > > + > > +Table: 3-byte opcode 2 (0x0f 0x38) > > Referrer: 3-byte escape 1 > > AVXcode: 2 > > # 0x0f 0x38 0x00-0x0f > > @@ -789,12 +799,12 @@ f0: MOVBE Gy,My | MOVBE Gw,Mw (66) | CRC32 Gd,Eb (F2) | CRC32 Gd,Eb (66&F2) > > f1: MOVBE My,Gy | MOVBE Mw,Gw (66) | CRC32 Gd,Ey (F2) | CRC32 Gd,Ew (66&F2) > > f2: ANDN Gy,By,Ey (v) > > f3: Grp17 (1A) > > -f5: BZHI Gy,Ey,By (v) | PEXT Gy,By,Ey (F3),(v) | PDEP Gy,By,Ey (F2),(v) > > -f6: ADCX Gy,Ey (66) | ADOX Gy,Ey (F3) | MULX By,Gy,rDX,Ey (F2),(v) > > +f5: BZHI Gy,Ey,By (v) | PEXT Gy,By,Ey (F3),(v) | PDEP Gy,By,Ey (F2),(v) | WRUSS Pq,Qq (66),REX.W > > +f6: ADCX Gy,Ey (66) | ADOX Gy,Ey (F3) | MULX By,Gy,rDX,Ey (F2),(v) | WRSS Pq,Qq (66),REX.W > > AFAICT WRSS does not have 66 prefix I will check. Thanks, Yu-cheng From mboxrd@z Thu Jan 1 00:00:00 1970 From: Yu-cheng Yu Subject: Re: [PATCH v7 27/27] x86/cet/shstk: Add Shadow Stack instructions to opcode map Date: Fri, 01 Nov 2019 07:17:45 -0700 Message-ID: <221c36d6646ea9f88d208dc02494872a34d8b61f.camel@intel.com> References: <20190606200646.3951-1-yu-cheng.yu@intel.com> <20190606200646.3951-28-yu-cheng.yu@intel.com> <93e915b9-975d-9876-8f89-8b6f2bc4586e@intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <93e915b9-975d-9876-8f89-8b6f2bc4586e@intel.com> Sender: linux-kernel-owner@vger.kernel.org To: Adrian Hunter , x86@kernel.org, "H. Peter Anvin" , Thomas Gleixner , Ingo Molnar , linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, linux-mm@kvack.org, linux-arch@vger.kernel.org, linux-api@vger.kernel.org, Arnd Bergmann , Andy Lutomirski , Balbir Singh , Borislav Petkov , Cyrill Gorcunov , Dave Hansen , Eugene Syromiatnikov , Florian Weimer , "H.J. Lu" , Jann Horn , Jonathan Corbet , Kees Cook , Mike Kravetz List-Id: linux-api@vger.kernel.org On Fri, 2019-11-01 at 16:03 +0200, Adrian Hunter wrote: > On 6/06/19 11:06 PM, Yu-cheng Yu wrote: > > Add the following shadow stack management instructions. > > > > INCSSP: > > Increment shadow stack pointer by the steps specified. > > > > RDSSP: > > Read SSP register into a GPR. > > > > SAVEPREVSSP: > > Use "prev ssp" token at top of current shadow stack to > > create a "restore token" on previous shadow stack. > > > > RSTORSSP: > > Restore from a "restore token" pointed by a GPR to SSP. > > > > WRSS: > > Write to kernel-mode shadow stack (kernel-mode instruction). > > > > WRUSS: > > Write to user-mode shadow stack (kernel-mode instruction). > > > > SETSSBSY: > > Verify the "supervisor token" pointed by IA32_PL0_SSP MSR, > > if valid, set the token to busy, and set SSP to the value > > of IA32_PL0_SSP MSR. > > > > CLRSSBSY: > > Verify the "supervisor token" pointed by a GPR, if valid, > > clear the busy bit from the token. > > Does the notrack prefix also need to be catered for somehow? Yes, I will fix it. > > > > > Signed-off-by: Yu-cheng Yu > > --- > > arch/x86/lib/x86-opcode-map.txt | 26 +++++++++++++------ > > tools/objtool/arch/x86/lib/x86-opcode-map.txt | 26 +++++++++++++------ > > 2 files changed, 36 insertions(+), 16 deletions(-) > > > > diff --git a/arch/x86/lib/x86-opcode-map.txt b/arch/x86/lib/x86-opcode-map.txt > > index e0b85930dd77..c5e825d44766 100644 > > --- a/arch/x86/lib/x86-opcode-map.txt > > +++ b/arch/x86/lib/x86-opcode-map.txt > > @@ -366,7 +366,7 @@ AVXcode: 1 > > 1b: BNDCN Gv,Ev (F2) | BNDMOV Ev,Gv (66) | BNDMK Gv,Ev (F3) | BNDSTX Ev,Gv > > 1c: > > 1d: > > -1e: > > +1e: RDSSP Rd (F3),REX.W > > 1f: NOP Ev > > # 0x0f 0x20-0x2f > > 20: MOV Rd,Cd > > @@ -610,7 +610,17 @@ fe: paddd Pq,Qq | vpaddd Vx,Hx,Wx (66),(v1) > > ff: UD0 > > EndTable > > > > -Table: 3-byte opcode 1 (0x0f 0x38) > > +Table: 3-byte opcode 1 (0x0f 0x01) > > +Referrer: > > +AVXcode: > > +# Skip 0x00-0xe7 > > +e8: SETSSBSY (f3) > > +e9: > > +ea: SAVEPREVSSP (f3) > > +# Skip 0xeb-0xff > > +EndTable > > + > > +Table: 3-byte opcode 2 (0x0f 0x38) > > Referrer: 3-byte escape 1 > > AVXcode: 2 > > # 0x0f 0x38 0x00-0x0f > > @@ -789,12 +799,12 @@ f0: MOVBE Gy,My | MOVBE Gw,Mw (66) | CRC32 Gd,Eb (F2) | CRC32 Gd,Eb (66&F2) > > f1: MOVBE My,Gy | MOVBE Mw,Gw (66) | CRC32 Gd,Ey (F2) | CRC32 Gd,Ew (66&F2) > > f2: ANDN Gy,By,Ey (v) > > f3: Grp17 (1A) > > -f5: BZHI Gy,Ey,By (v) | PEXT Gy,By,Ey (F3),(v) | PDEP Gy,By,Ey (F2),(v) > > -f6: ADCX Gy,Ey (66) | ADOX Gy,Ey (F3) | MULX By,Gy,rDX,Ey (F2),(v) > > +f5: BZHI Gy,Ey,By (v) | PEXT Gy,By,Ey (F3),(v) | PDEP Gy,By,Ey (F2),(v) | WRUSS Pq,Qq (66),REX.W > > +f6: ADCX Gy,Ey (66) | ADOX Gy,Ey (F3) | MULX By,Gy,rDX,Ey (F2),(v) | WRSS Pq,Qq (66),REX.W > > AFAICT WRSS does not have 66 prefix I will check. Thanks, Yu-cheng From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.2 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_SANE_2 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 732A1CA9ECF for ; Fri, 1 Nov 2019 14:28:03 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 416E421734 for ; Fri, 1 Nov 2019 14:28:02 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 416E421734 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id D969F6B0007; Fri, 1 Nov 2019 10:28:01 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D468F6B000C; Fri, 1 Nov 2019 10:28:01 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C5C516B000E; Fri, 1 Nov 2019 10:28:01 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0096.hostedemail.com [216.40.44.96]) by kanga.kvack.org (Postfix) with ESMTP id A48416B0007 for ; Fri, 1 Nov 2019 10:28:01 -0400 (EDT) Received: from smtpin14.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with SMTP id 434BA8249980 for ; Fri, 1 Nov 2019 14:28:01 +0000 (UTC) X-FDA: 76107937962.14.lead64_45dd3bc43d643 X-HE-Tag: lead64_45dd3bc43d643 X-Filterd-Recvd-Size: 5337 Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by imf23.hostedemail.com (Postfix) with ESMTP for ; Fri, 1 Nov 2019 14:27:59 +0000 (UTC) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 01 Nov 2019 07:27:58 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.68,255,1569308400"; d="scan'208";a="375578378" Received: from yyu32-desk1.sc.intel.com ([10.144.153.205]) by orsmga005.jf.intel.com with ESMTP; 01 Nov 2019 07:27:57 -0700 Message-ID: <221c36d6646ea9f88d208dc02494872a34d8b61f.camel@intel.com> Subject: Re: [PATCH v7 27/27] x86/cet/shstk: Add Shadow Stack instructions to opcode map From: Yu-cheng Yu To: Adrian Hunter , x86@kernel.org, "H. Peter Anvin" , Thomas Gleixner , Ingo Molnar , linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, linux-mm@kvack.org, linux-arch@vger.kernel.org, linux-api@vger.kernel.org, Arnd Bergmann , Andy Lutomirski , Balbir Singh , Borislav Petkov , Cyrill Gorcunov , Dave Hansen , Eugene Syromiatnikov , Florian Weimer , "H.J. Lu" , Jann Horn , Jonathan Corbet , Kees Cook , Mike Kravetz , Nadav Amit , Oleg Nesterov , Pavel Machek , Peter Zijlstra , Randy Dunlap , "Ravi V. Shankar" , Vedvyas Shanbhogue , Dave Martin Date: Fri, 01 Nov 2019 07:17:45 -0700 In-Reply-To: <93e915b9-975d-9876-8f89-8b6f2bc4586e@intel.com> References: <20190606200646.3951-1-yu-cheng.yu@intel.com> <20190606200646.3951-28-yu-cheng.yu@intel.com> <93e915b9-975d-9876-8f89-8b6f2bc4586e@intel.com> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.28.1-2 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Fri, 2019-11-01 at 16:03 +0200, Adrian Hunter wrote: > On 6/06/19 11:06 PM, Yu-cheng Yu wrote: > > Add the following shadow stack management instructions. > > > > INCSSP: > > Increment shadow stack pointer by the steps specified. > > > > RDSSP: > > Read SSP register into a GPR. > > > > SAVEPREVSSP: > > Use "prev ssp" token at top of current shadow stack to > > create a "restore token" on previous shadow stack. > > > > RSTORSSP: > > Restore from a "restore token" pointed by a GPR to SSP. > > > > WRSS: > > Write to kernel-mode shadow stack (kernel-mode instruction). > > > > WRUSS: > > Write to user-mode shadow stack (kernel-mode instruction). > > > > SETSSBSY: > > Verify the "supervisor token" pointed by IA32_PL0_SSP MSR, > > if valid, set the token to busy, and set SSP to the value > > of IA32_PL0_SSP MSR. > > > > CLRSSBSY: > > Verify the "supervisor token" pointed by a GPR, if valid, > > clear the busy bit from the token. > > Does the notrack prefix also need to be catered for somehow? Yes, I will fix it. > > > > > Signed-off-by: Yu-cheng Yu > > --- > > arch/x86/lib/x86-opcode-map.txt | 26 +++++++++++++------ > > tools/objtool/arch/x86/lib/x86-opcode-map.txt | 26 +++++++++++++------ > > 2 files changed, 36 insertions(+), 16 deletions(-) > > > > diff --git a/arch/x86/lib/x86-opcode-map.txt b/arch/x86/lib/x86-opcode-map.txt > > index e0b85930dd77..c5e825d44766 100644 > > --- a/arch/x86/lib/x86-opcode-map.txt > > +++ b/arch/x86/lib/x86-opcode-map.txt > > @@ -366,7 +366,7 @@ AVXcode: 1 > > 1b: BNDCN Gv,Ev (F2) | BNDMOV Ev,Gv (66) | BNDMK Gv,Ev (F3) | BNDSTX Ev,Gv > > 1c: > > 1d: > > -1e: > > +1e: RDSSP Rd (F3),REX.W > > 1f: NOP Ev > > # 0x0f 0x20-0x2f > > 20: MOV Rd,Cd > > @@ -610,7 +610,17 @@ fe: paddd Pq,Qq | vpaddd Vx,Hx,Wx (66),(v1) > > ff: UD0 > > EndTable > > > > -Table: 3-byte opcode 1 (0x0f 0x38) > > +Table: 3-byte opcode 1 (0x0f 0x01) > > +Referrer: > > +AVXcode: > > +# Skip 0x00-0xe7 > > +e8: SETSSBSY (f3) > > +e9: > > +ea: SAVEPREVSSP (f3) > > +# Skip 0xeb-0xff > > +EndTable > > + > > +Table: 3-byte opcode 2 (0x0f 0x38) > > Referrer: 3-byte escape 1 > > AVXcode: 2 > > # 0x0f 0x38 0x00-0x0f > > @@ -789,12 +799,12 @@ f0: MOVBE Gy,My | MOVBE Gw,Mw (66) | CRC32 Gd,Eb (F2) | CRC32 Gd,Eb (66&F2) > > f1: MOVBE My,Gy | MOVBE Mw,Gw (66) | CRC32 Gd,Ey (F2) | CRC32 Gd,Ew (66&F2) > > f2: ANDN Gy,By,Ey (v) > > f3: Grp17 (1A) > > -f5: BZHI Gy,Ey,By (v) | PEXT Gy,By,Ey (F3),(v) | PDEP Gy,By,Ey (F2),(v) > > -f6: ADCX Gy,Ey (66) | ADOX Gy,Ey (F3) | MULX By,Gy,rDX,Ey (F2),(v) > > +f5: BZHI Gy,Ey,By (v) | PEXT Gy,By,Ey (F3),(v) | PDEP Gy,By,Ey (F2),(v) | WRUSS Pq,Qq (66),REX.W > > +f6: ADCX Gy,Ey (66) | ADOX Gy,Ey (F3) | MULX By,Gy,rDX,Ey (F2),(v) | WRSS Pq,Qq (66),REX.W > > AFAICT WRSS does not have 66 prefix I will check. Thanks, Yu-cheng