Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp112492imu; Thu, 8 Nov 2018 15:55:01 -0800 (PST) X-Google-Smtp-Source: AJdET5eFHjbsbhbH/82WjYo+XGTuzSsdbzHTywVjdwBpEHNgJRhfQv+2q5LqYtcEgric179ZIM23 X-Received: by 2002:a63:1d10:: with SMTP id d16-v6mr5353574pgd.228.1541721301662; Thu, 08 Nov 2018 15:55:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541721301; cv=none; d=google.com; s=arc-20160816; b=ufZzEixLB1u+kin1Why7er/MwBXOdSn99ndzxsLmp5sc25Evsh7zXIewuDd1TDS1ML XO4mvVISyTuANTm47oZemzhRYQX50Ou91fqKFPCYoJOZnK3ric3WMbVoAEk/vF+8WiDj E4U8m1Z2Jf+ndTY5H+9iCAOkynIn5UN78LAS2Jt8dp6FbGhDKl26zl9TF8z6ID+sZHno QH2tJwUavxFwr+ZCk00gI9iTgLvwOOC90nzn4sLf3hzzZVKCeF3oWAwo1IB5SPTf8/d/ wIzL7HZ8/O0xY6QDWS3Dm8LmPbsxfNEGRIGlDDjzlb2Sw9jK8f32HBuQZ5RSJKYcRHa5 r4xQ== 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; bh=+siVlOgtD1tQu0aJ96eI++tGDQYH0r/iQIPobDhZwns=; b=otCrHS6XhVFJMuFT0wieir4LWW5quRqkWFRdQogNpOlPl7FNcoDd1uxTQ0b43z8moa Z/VfIDoIFDnAikyHQemAnLC0EGo5QUWBXkiRHI+Vnr3NLkorm76h/ACkS2cup7KwNAgb YBBjJHfnNtbxRzWlEs5Koqi6aAba0q4WPoDDGReJ06P4gR6Mk//gj3dZueGWDgh9QQ1M YWk92KK9Eo7k87nz68aECV/tYf+wImVWqD9GA0KN5kMhZpltYTGLLno11P/aQpoCMbBY iG3OwEw6jutF6mZ22wJRgK/xUCwRU1p7B9iV/FtvDsQuuP9eOYIhdLJOrF44uVN8G2FC 99MQ== ARC-Authentication-Results: i=1; mx.google.com; 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 m1-v6si4873578pgb.476.2018.11.08.15.54.46; Thu, 08 Nov 2018 15:55:01 -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; 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 S1727638AbeKIJa6 (ORCPT + 99 others); Fri, 9 Nov 2018 04:30:58 -0500 Received: from mail.skyhub.de ([5.9.137.197]:33266 "EHLO mail.skyhub.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727016AbeKIJa6 (ORCPT ); Fri, 9 Nov 2018 04:30:58 -0500 X-Virus-Scanned: Nedap ESD1 at mail.skyhub.de Received: from mail.skyhub.de ([127.0.0.1]) by localhost (blast.alien8.de [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id fNVI4CNEJSxL; Fri, 9 Nov 2018 00:52:59 +0100 (CET) Received: from zn.tnic (p200300EC2BD03D00329C23FFFEA6A903.dip0.t-ipconnect.de [IPv6:2003:ec:2bd0:3d00:329c:23ff:fea6:a903]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.skyhub.de (SuperMail on ZX Spectrum 128k) with ESMTPSA id 060FD1EC026E; Fri, 9 Nov 2018 00:52:59 +0100 (CET) Date: Fri, 9 Nov 2018 00:52:44 +0100 From: Borislav Petkov To: Yu-cheng Yu Cc: 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 , 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 Subject: Re: [PATCH v5 04/27] x86/fpu/xstate: Add XSAVES system states for shadow stack Message-ID: <20181108235244.GK7543@zn.tnic> References: <20181011151523.27101-1-yu-cheng.yu@intel.com> <20181011151523.27101-5-yu-cheng.yu@intel.com> <20181108184038.GJ7543@zn.tnic> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Nov 08, 2018 at 12:40:02PM -0800, Yu-cheng Yu wrote: > In fpu_init_system_xstate(), we test and clear features that are not enabled. > There we depend on the order of these elements. This is the tenth "unknown > xstate feature". Aha, those are *reserved* bits - not unused, in XCR0. Do an s/unused/reserved/g pls. Now let's see, you have 0 for the 10th bit which happens to be #define X86_FEATURE_FPU ( 0*32+ 0) /* Onboard FPU */ too. And if we look at the code: for (i = 0; i < ARRAY_SIZE(xsave_cpuid_features); i++) { if (!boot_cpu_has(xsave_cpuid_features[i])) xfeatures_mask_all &= ~BIT_ULL(i); guess what happens if i == 10. I know, the subsequent & SUPPORTED_XFEATURES_MASK saves you from the #GP but that's still not good enough. The loop should not even call boot_cpu_has() for reserved feature bits. Thx. -- Regards/Gruss, Boris. Good mailing practices for 400: avoid top-posting and trim the reply.