Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp5594228ybf; Thu, 5 Mar 2020 03:34:00 -0800 (PST) X-Google-Smtp-Source: ADFU+vtBryJE15KkFbY/WT/oVGkrCLmnU3/KfIcTqBwFzs7bBHAElk8ch2JedZTUEjKDyfFfV7ez X-Received: by 2002:aca:4b57:: with SMTP id y84mr5457823oia.16.1583408040721; Thu, 05 Mar 2020 03:34:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1583408040; cv=none; d=google.com; s=arc-20160816; b=gpsqFwbqgGmf5sqFCymGRmvt+o+r8LRKgajTBtb6l9VB+eRYydzLlh3khA4hZeYrHA AZxViTBsUtNQMnANshsWL5ZL1YP/Uqa9d15Ct1CUhWtzYMLV+NyRkXFs8DK4YH+UxpIr phhPN8PuF3xMkaz7zyO937RWdd5TQp02J+iNqBrlMaqWXWPPUTD6s9qwyJHg/Hmx8F7h sGMwfGnE5FUMOdJHh5MusmOD8fEdjaON1Mc+S3X/bcZoh2Jn99ze/kis/zudSXjCl8hk GqUA2ZqOQnvJBxRWzXRWZq5ldNdaYHeXPm0UREHhJOtjaVivKpkPCxYoQV6cfnfJOZtQ Gsfg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:organization:references:in-reply-to:date:cc:to:from :subject:message-id; bh=W5bBzmVyB7Ze3cNj24hpB0rrXKBOzUtaXwKXhyh/4fw=; b=dU2EzW+OXIGTE64OSv0Q6qLNCRNoErFrVUdUpKcIcNx+QqcfS4HoU6kFBqE38THAUg h/JG/DjN4dSfS06jrl1I86/oSHt6krUpWAgYO1knHIW8G/J1Z5iQ/KdNDwdBxKxFvXOZ ZVhQNXf/r/f6qnPM85PG7VMt2696gGtsj7b+yELJPaHF2kVHWzqYtXAgq6xnZzE8IygL N1xChtSZWagIQvLzpcS3uOJtHBTeqc8qyeVdWEIy7q6KnebVnJcV/me6afuW2H4QnfLR RlPEd5kwlUbtjNhLvAWgFIBb3PnC6XDPYcAJKoV2CJa7WbdKcuPhpIs3MVWCtw/HDKZS /IyA== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l19si3146245oii.54.2020.03.05.03.33.47; Thu, 05 Mar 2020 03:34:00 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726635AbgCELdd (ORCPT + 99 others); Thu, 5 Mar 2020 06:33:33 -0500 Received: from mga02.intel.com ([134.134.136.20]:23507 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725816AbgCELdc (ORCPT ); Thu, 5 Mar 2020 06:33:32 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 05 Mar 2020 03:33:32 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.70,517,1574150400"; d="scan'208";a="234387456" Received: from unknown (HELO jsakkine-mobl1) ([10.237.50.161]) by orsmga008.jf.intel.com with ESMTP; 05 Mar 2020 03:33:27 -0800 Message-ID: <04362c0cf66bf66e8f7c25a531830b9f294d2d09.camel@linux.intel.com> Subject: Re: [PATCH v28 14/22] selftests/x86: Add a selftest for SGX From: Jarkko Sakkinen To: Nathaniel McCallum Cc: linux-kernel@vger.kernel.org, x86@kernel.org, linux-sgx@vger.kernel.org, akpm@linux-foundation.org, dave.hansen@intel.com, "Christopherson, Sean J" , Neil Horman , "Huang, Haitao" , andriy.shevchenko@linux.intel.com, tglx@linutronix.de, "Svahn, Kai" , bp@alien8.de, Josh Triplett , luto@kernel.org, kai.huang@intel.com, rientjes@google.com, cedric.xing@intel.com, Patrick Uiterwijk , linux-kselftest@vger.kernel.org Date: Thu, 05 Mar 2020 13:33:28 +0200 In-Reply-To: References: <20200303233609.713348-1-jarkko.sakkinen@linux.intel.com> <20200303233609.713348-15-jarkko.sakkinen@linux.intel.com> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.35.92-1 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 2020-03-04 at 14:27 -0500, Nathaniel McCallum wrote: > > > +xsave_area: > > + .fill 1, 4, 0x037F # FCW > > + .fill 5, 4, 0 > > + .fill 1, 4, 0x1F80 # MXCSR > > + .fill 1, 4, 0xFFFF # MXCSR_MASK > > + .fill 123, 4, 0 > > + .fill 1, 4, 0x80000000 # XCOMP_BV[63] = 1, compaction mode > > + .fill 12, 4, 0 > > I find this much more readable: And I always aim to get things more readable. Thank you. > xsave_area: > # Legacy > .fill 1, 4, 0x037F # FCW > .fill 5, 4, 0 > .fill 1, 4, 0x1F80 # MXCSR > .fill 1, 4, 0xFFFF # MXCSR_MASK > .fill 60, 8, 0 > > # Header > .fill 1, 8, 0 # XSTATE_BV > .fill 1, 8, 1 << 63 # XCOMP_BV (compaction mode) > .fill 6, 8, 0 > > Also, since people are likely to copy this code for their own > enclaves, it would be helpful to document which flags are set in FCW > and MXCSR. It was meant as a test program but I'd guess what you say is true because it also might be the only alternative user space to Intel's :-) And a great starting point if you want to do things from scratch. Because I meant it as a smoke test program for SGX, not everything is too well documented but given the multipurpose use for that code I'll make the improvements that you are suggesting. /Jarkko