From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752406AbdFOOdU (ORCPT ); Thu, 15 Jun 2017 10:33:20 -0400 Received: from mga11.intel.com ([192.55.52.93]:16695 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752037AbdFOOdU (ORCPT ); Thu, 15 Jun 2017 10:33:20 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.39,343,1493708400"; d="scan'208";a="98301408" Subject: Re: xgetbv nondeterminism To: Andy Lutomirski , "Robert O'Callahan" , "linux-kernel@vger.kernel.org" , X86 ML References: From: Dave Hansen Message-ID: <1eb55c22-6c90-e1b3-19d4-cb7b2c6fc0dc@intel.com> Date: Thu, 15 Jun 2017 07:33:18 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.1.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 06/14/2017 10:18 PM, Andy Lutomirski wrote: > Dave, why is XINUSE exposed at all to userspace? You need it for XSAVEOPT when it is using the init optimization to be able to tell which state was written and which state in the XSAVE buffer is potentially stale with respect to what's in the registers. I guess you can just use XSAVE instead of XSAVEOPT, though. As you pointed out, if you are using XSAVEC's compaction features by leaving bits unset in the requested feature bitmap registers, you have no idea how much data XSAVEC will write, unless you read XINUSE with XGETBV. But, you can get around *that* by just presizing the XSAVE buffer to be big. So, I guess that leaves its use to just figuring out how much XSAVEOPT (and friends) are going to write. > To be fair, glibc uses this new XGETBV feature, but I suspect its > usage is rather dubious. Shouldn't it just do XSAVEC directly rather > than rolling its own code? A quick grep through my glibc source only shows XGETBV(0) used which reads XCR0. I don't see any XGETBV(1) which reads XINUSE. Did I miss it.