Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1000761imu; Fri, 9 Nov 2018 09:19:33 -0800 (PST) X-Google-Smtp-Source: AJdET5eOSLJJPBm0VHSj/LJLGNBj7nXOnvwakzMB3Hi8/tIMVpscAVska4qDibn5MZ2Q1xx5MGEG X-Received: by 2002:a17:902:8543:: with SMTP id d3-v6mr9769908plo.313.1541783973425; Fri, 09 Nov 2018 09:19:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541783973; cv=none; d=google.com; s=arc-20160816; b=ArlNd9CJWqz4y5adfz97YD1V/JoRA3vT4q1PwWjEMEIyZemtIr8gTQEu7sHT6eGZWI vMv7Zv/i8jjVgrXSvsuDCtWeP4/svG78zkCy81VVilYk0N+mxRhjBZIG2jqsItdIgRcF ygnCok0tX01NCZ3TKqxXh9JRWGF1SDYNe2b3Agw8xOjiB3SpZwhoh3eBqL2Us759WMJt qOE9Zd+/ECXIx7hg2XhTECdWKoRvo4YJRHdO9zx2xYuT08/ypAAqiNGF1P96r05xbMG9 Bd3k9sl0qWhANfwcpD/4rW6A/BfF3CPqDFDoXIgVrHiQBnctjXt/TLJ1d2T20pFhVf48 CPgw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=jLpnOVJ+M6GvWpdCZ7qu/Ypx8ghGwTs4p32VfyHKziw=; b=bb+5QxFxu31Ijfo21b0aHaHxW5yOmEbbp5JN6WtFT9i3CtPDm6v2ECMdzw3hc04Xtz y/qDaberBO5XFsBMQL0stRozGsLINjlMT2sSYfDHzhr9RqIJeqrRphkp6pY5Y2voOSRB b+HGfeXwC8ArJ5YhTbIZ4Vx+Tr9sNaU2Lf+I4fO2bpyFqH0Uwaui1xIej+s6HTo32RP+ I1bnUL3TNjwSLlYoO0RZhZv1m3RzTOEQtn8gSu2StNQQ89SNwvMLW+ZVwEAzP33EVE0D 2GqXmY2Ky+jafDYKqtXkuNA5HDnTX4lnLf4u4TMzvUooZTR3lzXQyCMm37zSHvQHkDf+ 43dQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=HHb7MlT4; 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 k4-v6si7336264pgg.527.2018.11.09.09.19.05; Fri, 09 Nov 2018 09:19:33 -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=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=HHb7MlT4; 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 S1728615AbeKJC7S (ORCPT + 99 others); Fri, 9 Nov 2018 21:59:18 -0500 Received: from bombadil.infradead.org ([198.137.202.133]:47770 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727961AbeKJC7R (ORCPT ); Fri, 9 Nov 2018 21:59:17 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=jLpnOVJ+M6GvWpdCZ7qu/Ypx8ghGwTs4p32VfyHKziw=; b=HHb7MlT4TNKDVH0wMHL7m7ODn namrqgoBWSD6fpGjNMAxVe50j65z7T9mngzINKy/z/E1qeArPs0yS/uY/pucASJ6Si+R58cKvFHrk HqsPgc6ukbBksRmJjukgvIaUwbrExWglWkUKKJtAAoKwNIhGXCmu++CqVXIA6xmyc9pyz7KkRB6eW VzabVXJJnshEDKwuVjW+Wr2kRWPHaVGOieqgHQrUIL8iC6VDlc3vt7gbKzC22iUJpyeE0B2ejh2zv f3MRfXFRM41tGyOuXWugNO+ltJAnkB4bXJF3jIEgiN+WOADFSWdsYpBQtYCKb+cY7D5x9o+9i86JT WZfBFT4UQ==; Received: from willy by bombadil.infradead.org with local (Exim 4.90_1 #2 (Red Hat Linux)) id 1gLAPd-0006pj-1i; Fri, 09 Nov 2018 17:17:41 +0000 Date: Fri, 9 Nov 2018 09:17:40 -0800 From: Matthew Wilcox To: Dave Hansen Cc: Andy Lutomirski , 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 , Pavel Machek , Peter Zijlstra , Randy Dunlap , "Ravi V. Shankar" , "Shanbhogue, Vedvyas" Subject: Re: [PATCH v5 04/27] x86/fpu/xstate: Add XSAVES system states for shadow stack Message-ID: <20181109171740.GT3074@bombadil.infradead.org> References: <20181011151523.27101-1-yu-cheng.yu@intel.com> <20181011151523.27101-5-yu-cheng.yu@intel.com> <4295b8f786c10c469870a6d9725749ce75dcdaa2.camel@intel.com> <043a17ef-dc9f-56d2-5fba-1a58b7b0fd4d@intel.com> <20181108220054.GP3074@bombadil.infradead.org> <20181109003225.GQ3074@bombadil.infradead.org> <6cd2ae51-2d2a-9c68-df7c-45b49e0a813f@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <6cd2ae51-2d2a-9c68-df7c-45b49e0a813f@intel.com> User-Agent: Mutt/1.9.2 (2017-12-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Nov 09, 2018 at 09:13:32AM -0800, Dave Hansen wrote: > On 11/8/18 4:32 PM, Matthew Wilcox wrote: > >> Now, looking at Yu-cheng's specific example, it doesn't matter. We've > >> got 64-bit types and natural 64-bit alignment. Without __packed, we > >> need to look out for natural alignment screwing us up. With __packed, > >> it just does what it *looks* like it does. > > The question is whether Yu-cheng's struct is ever embedded in another > > struct. And if so, what does the hardware do? > > It's not really. > > +struct cet_user_state { > + u64 u_cet; /* user control flow settings */ > + u64 user_ssp; /* user shadow stack pointer */ > +} __packed; > > This ends up embedded in 'struct fpu'. The hardware tells us what the > sum of all the sizes of all the state components are, and also tells us > the offsets inside the larger buffer. > > We double-check that the structure sizes exactly match the sizes that > the hardware tells us that the buffer pieces are via XCHECK_SZ(). > > But, later versions of the hardware have instructions that don't have > static offsets for the state components (when the XSAVES/XSAVEC > instructions are used). So, for those, the structure embedding isn't > used at *all* since some state might not be present. But *when present*, this structure is always aligned on an 8-byte boundary, right?