From mboxrd@z Thu Jan 1 00:00:00 1970 From: Pavel Machek Subject: Re: [PATCH v5 04/27] x86/fpu/xstate: Add XSAVES system states for shadow stack Date: Sun, 11 Nov 2018 12:31:25 +0100 Message-ID: <20181111113125.GI27666@amd> References: <20181011151523.27101-1-yu-cheng.yu@intel.com> <20181011151523.27101-5-yu-cheng.yu@intel.com> <4295b8f786c10c469870a6d9725749ce75dcdaa2.camel@intel.com> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="TA4f0niHM6tHt3xR" Return-path: Content-Disposition: inline In-Reply-To: Sender: linux-kernel-owner@vger.kernel.org To: Andy Lutomirski Cc: Yu-cheng Yu , 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 List-Id: linux-arch.vger.kernel.org --TA4f0niHM6tHt3xR Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable > > > > +/* > > > > + * 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. > > > > That prevents any possibility that the compiler will insert padding, al= though in > > 64-bit kernel this should not happen to either struct. Also all xstate > > components here are packed. > > >=20 > They both seem like bugs, perhaps. As I understand it, __packed > removes padding, but it also forces the compiler to expect the fields > to be unaligned even if they are actually aligned. This structure is shared with hardware, right? __packed seems like right thing to do semantically. As x86 handles unaligned accesses automatically, there should not be much difference either way. Pavel --=20 (english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blo= g.html --TA4f0niHM6tHt3xR Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iEYEARECAAYFAlvoEw0ACgkQMOfwapXb+vLY1gCglZ9VACt9vxNg/QC9O9on/sJW mGoAnA825hlJ7l0ichrQ9oFwIh31PPDp =dUic -----END PGP SIGNATURE----- --TA4f0niHM6tHt3xR-- From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from atrey.karlin.mff.cuni.cz ([195.113.26.193]:44281 "EHLO atrey.karlin.mff.cuni.cz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727556AbeKKVTr (ORCPT ); Sun, 11 Nov 2018 16:19:47 -0500 Date: Sun, 11 Nov 2018 12:31:25 +0100 From: Pavel Machek Subject: Re: [PATCH v5 04/27] x86/fpu/xstate: Add XSAVES system states for shadow stack Message-ID: <20181111113125.GI27666@amd> References: <20181011151523.27101-1-yu-cheng.yu@intel.com> <20181011151523.27101-5-yu-cheng.yu@intel.com> <4295b8f786c10c469870a6d9725749ce75dcdaa2.camel@intel.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="TA4f0niHM6tHt3xR" Content-Disposition: inline In-Reply-To: Sender: linux-arch-owner@vger.kernel.org List-ID: To: Andy Lutomirski Cc: Yu-cheng Yu , 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 , Peter Zijlstra , Randy Dunlap , "Ravi V. Shankar" , "Shanbhogue, Vedvyas" Message-ID: <20181111113125.ZF3zzPhjPjZ8X2eqxmCVT4SkCv2Zh7XQQV6caOLAh2E@z> --TA4f0niHM6tHt3xR Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable > > > > +/* > > > > + * 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. > > > > That prevents any possibility that the compiler will insert padding, al= though in > > 64-bit kernel this should not happen to either struct. Also all xstate > > components here are packed. > > >=20 > They both seem like bugs, perhaps. As I understand it, __packed > removes padding, but it also forces the compiler to expect the fields > to be unaligned even if they are actually aligned. This structure is shared with hardware, right? __packed seems like right thing to do semantically. As x86 handles unaligned accesses automatically, there should not be much difference either way. Pavel --=20 (english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blo= g.html --TA4f0niHM6tHt3xR Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iEYEARECAAYFAlvoEw0ACgkQMOfwapXb+vLY1gCglZ9VACt9vxNg/QC9O9on/sJW mGoAnA825hlJ7l0ichrQ9oFwIh31PPDp =dUic -----END PGP SIGNATURE----- --TA4f0niHM6tHt3xR--