Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp741imu; Thu, 8 Nov 2018 12:47:41 -0800 (PST) X-Google-Smtp-Source: AJdET5fNuXRKiYaS1hPTuWOl93rA3sE5Hq2O+U5JYtzGGj44HUGdRrSEEPr7aW/hWSvzhZ1fXJYX X-Received: by 2002:a63:1b1f:: with SMTP id b31mr4988736pgb.66.1541710061425; Thu, 08 Nov 2018 12:47:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541710061; cv=none; d=google.com; s=arc-20160816; b=CyvZpqqcvfS2/E2zevu6qT7OeHLrkMmHcWjB70F+TOsiEV9js/YITJg8HZlfDTFKJw gtrM6EZ93GaMyyj81cZ5NBv5xi8Q3oVdfzB/Q+5MbKgHRQH+WlmY70mUeX+8JLgUolek yjAJGxvYKhow2E3cUayfqxfX+Wzxup6AcH0kzLa0poOufl7evUrDkTmjaNT2iMsDg+bN Z5v1ktkipLvBf590OeVbAFDrkV6RA8TFl3xSShBL7D1GtyE0f6v2/ereuR6/7dFQIK2m QgV8a1oo71GkpKHR7vG9f3JwGAVUDnfWd85EFU3Xw5oWinqWR0p4Y+2BpcgsLKRC4F+N Q5iQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=DLl2v3vIw7M0YRcW5fy9V9s5+BwSa4Xzl7tiDfa/DtQ=; b=o2+rSq0MWGYXq27frcSZia4QvVTY4KRJgV7tefv6fjavbKlgQ+IjMpwIbXGQiAwFpd 4qa1T0ewL57OIfw2YBoiphPqiXsVbv9W8Q6+Cnmo5p64LMMSqKwySwMgh4LNPdDWHsPR hIrg6Wi/huLD/GwY49uVBbIMCM6BMl6hgLxMI3HRANiUN1IJeFxuLlfFUFPeGEj+aFQp VbSwwwKZ03zyzaKUVdkGCsZmS/RuxpbOELSGwY1lfLa8RVgY8L8BFUfmypHMEE3qHy57 MYxFoMdIGbRrJBe/PlYhEDPmyxJcwX5AYGNzzKcDUq9a3MC1wmNHfckoEWxZwFUKMs06 1cCw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amacapital-net.20150623.gappssmtp.com header.s=20150623 header.b=OGaoTl5b; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d31-v6si5526826pla.27.2018.11.08.12.47.22; Thu, 08 Nov 2018 12:47:41 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@amacapital-net.20150623.gappssmtp.com header.s=20150623 header.b=OGaoTl5b; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727265AbeKIGXx (ORCPT + 99 others); Fri, 9 Nov 2018 01:23:53 -0500 Received: from mail-wr1-f65.google.com ([209.85.221.65]:34607 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726875AbeKIGXx (ORCPT ); Fri, 9 Nov 2018 01:23:53 -0500 Received: by mail-wr1-f65.google.com with SMTP id j26-v6so22723618wre.1 for ; Thu, 08 Nov 2018 12:46:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amacapital-net.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=DLl2v3vIw7M0YRcW5fy9V9s5+BwSa4Xzl7tiDfa/DtQ=; b=OGaoTl5bZvC9kcZMZ5J7lTfdHXQQAVXjRK1OqlZwyTQ4Tb8BKh3noqY2Gre4c+qQRv 4vDwf6ZPuvbnrgYAk/VCZmA0+gpu4vZFANsi0eUASrwFqAX+67F88Q2GietX/vqLviYZ gzw9dGo8JwcLXZ6SOs5YvJ2LZ5KbNUwiu85XdZa3CsbFHCrFbVb1WAIa6QM4w8JGMI5B W+NEEaDokByG2UaagkODirIEjmtFw9EA7IKaBf429uM0k8tjPmpa5y6Yy5b6GRM/QzfG 2vUSnRWLcRc4z/D/9AlPUdIxpgtgEhHf7Cxmx4Gna5G1GBejneZ4n/zpFA/IQZlfYC7b K02A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=DLl2v3vIw7M0YRcW5fy9V9s5+BwSa4Xzl7tiDfa/DtQ=; b=InmADm31pmNtAUw3eq0OCyzyYJE1MVSo+QjNYsEBx/PRip5i69cLA+6ZAjeu7r+jix 3Of/BXD/RtIyzb8xFiPdlT0twqQWqrkQiRfvT1WkYWja8/HIx/xNgADpG8I8KcYPF1ey 138+C4Ztemzv6B/AUcO2IZkg8FKj8VINAEWOg5+HSaKZh1pSBnZ8Hz1OV8mHsqOpG2VH aIKEmILhHcuhM0w8xX1tyCIxy1RzRfCJFfpcGEsKrwo0mf6GVQ9FvKrjq95Y+fqnSOxj an65tlMvKjIMZaJa72aZSjYq9oly2lk58RD4aiGhOokS8kifdvG4NX2gEzx0liKfUfOZ umqw== X-Gm-Message-State: AGRZ1gLIu504F+TUIvnmUiI64XIpx0wxkB7uajZWU2OE8HbvC3IsPsBM NyeOu9DPNHaMSSnTL4AWz6Eow+wlvkYWRlonKbQsPA== X-Received: by 2002:a5d:4450:: with SMTP id x16-v6mr5508356wrr.308.1541709999716; Thu, 08 Nov 2018 12:46:39 -0800 (PST) MIME-Version: 1.0 References: <20181011151523.27101-1-yu-cheng.yu@intel.com> <20181011151523.27101-5-yu-cheng.yu@intel.com> In-Reply-To: <20181011151523.27101-5-yu-cheng.yu@intel.com> From: Andy Lutomirski Date: Thu, 8 Nov 2018 12:46:29 -0800 Message-ID: Subject: Re: [PATCH v5 04/27] x86/fpu/xstate: Add XSAVES system states for shadow stack To: Yu-cheng Yu Cc: X86 ML , "H. Peter Anvin" , Thomas Gleixner , Ingo Molnar , LKML , "open list:DOCUMENTATION" , Linux-MM , linux-arch , Linux API , Arnd Bergmann , Balbir Singh , 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" , "Shanbhogue, Vedvyas" Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Oct 11, 2018 at 8:20 AM Yu-cheng Yu wrote: > > Intel Control-flow Enforcement Technology (CET) introduces the > following MSRs into the XSAVES system states. > > IA32_U_CET (user-mode CET settings), > IA32_PL3_SSP (user-mode shadow stack), > IA32_PL0_SSP (kernel-mode shadow stack), > IA32_PL1_SSP (ring-1 shadow stack), > IA32_PL2_SSP (ring-2 shadow stack). > > Signed-off-by: Yu-cheng Yu > --- > arch/x86/include/asm/fpu/types.h | 22 +++++++++++++++++++++ > arch/x86/include/asm/fpu/xstate.h | 4 +++- > arch/x86/include/uapi/asm/processor-flags.h | 2 ++ > arch/x86/kernel/fpu/xstate.c | 10 ++++++++++ > 4 files changed, 37 insertions(+), 1 deletion(-) > > diff --git a/arch/x86/include/asm/fpu/types.h b/arch/x86/include/asm/fpu/types.h > index 202c53918ecf..e55d51d172f1 100644 > --- a/arch/x86/include/asm/fpu/types.h > +++ b/arch/x86/include/asm/fpu/types.h > @@ -114,6 +114,9 @@ enum xfeature { > XFEATURE_Hi16_ZMM, > XFEATURE_PT_UNIMPLEMENTED_SO_FAR, > XFEATURE_PKRU, > + XFEATURE_RESERVED, > + XFEATURE_SHSTK_USER, > + XFEATURE_SHSTK_KERNEL, > > XFEATURE_MAX, > }; > @@ -128,6 +131,8 @@ enum xfeature { > #define XFEATURE_MASK_Hi16_ZMM (1 << XFEATURE_Hi16_ZMM) > #define XFEATURE_MASK_PT (1 << XFEATURE_PT_UNIMPLEMENTED_SO_FAR) > #define XFEATURE_MASK_PKRU (1 << XFEATURE_PKRU) > +#define XFEATURE_MASK_SHSTK_USER (1 << XFEATURE_SHSTK_USER) > +#define XFEATURE_MASK_SHSTK_KERNEL (1 << XFEATURE_SHSTK_KERNEL) > > #define XFEATURE_MASK_FPSSE (XFEATURE_MASK_FP | XFEATURE_MASK_SSE) > #define XFEATURE_MASK_AVX512 (XFEATURE_MASK_OPMASK \ > @@ -229,6 +234,23 @@ struct pkru_state { > u32 pad; > } __packed; > > +/* > + * State component 11 is Control flow Enforcement user states > + */ > +struct cet_user_state { > + u64 u_cet; /* user control flow settings */ > + u64 user_ssp; /* user shadow stack pointer */ > +} __packed; > + > +/* > + * State component 12 is Control flow Enforcement kernel states > + */ > +struct cet_kernel_state { > + u64 kernel_ssp; /* kernel shadow stack */ > + u64 pl1_ssp; /* ring-1 shadow stack */ > + u64 pl2_ssp; /* ring-2 shadow stack */ > +} __packed; > + Why are these __packed? It seems like it'll generate bad code for no obvious purpose.