Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp4409206imm; Mon, 18 Jun 2018 14:35:39 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKlXwFzsOUp8iIthzwD2EGwNDIpMhLGBPBeH8XNl7n5JyCraBSc0AcB0CQGg8SOotPdyEuU X-Received: by 2002:a62:fcb:: with SMTP id 72-v6mr15150168pfp.231.1529357739636; Mon, 18 Jun 2018 14:35:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529357739; cv=none; d=google.com; s=arc-20160816; b=jb0XLi/PTir7+2LwrfTN8IQNtp+XY+h0pbMGGm3X69fVeA2BiZ1TtHUyhxZF/5sDiu vvkXF/MMHsPGubcQ1OJfjsUPH31RZZ0rMf2n5b/eRw/X3LqGVIK3CdN3y1tqh2XCtBvz DPaY9aIjwd8NHOz1ThUOjUd1Z1cqyQDeWcATxbKY6EQv29AmhxKqwdHCl6TiEJdIV1qI GMcFCrobdMuRn/pvc7Mcg5GVB4CcfTvrCCoD0PAeGisZhkuf4inYTPoROZMyoCHUr7lW VQbuKciUTUBYNvO2GmVmXEEqCkg+gPLEj5uKg5W9EoYByTH5+n+3yYcpnz6KTXItperX iLLQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature :arc-authentication-results; bh=U6SkZ+f794cfZX+bD4EEfHaVHi7NRgWkYBMMBg6NRIM=; b=r0rJHdm56B0kRS8IH7fWboZcnp3fgbQ4kh/Jz5RuZfsF/YqnnE9RZDl8Nxlx1Z3vcf 5hbH8rre0mHUVZ+gtzdfKleIvjrYCRzlSIaK+uDVajNVJbIqU3nzvARdRY7IBH2M8COT 7hG0tcG2MSjxDJvkXIkkEoT/t5twPlFCmhHKiecuUHwQtnotz5dobElOE99T8uX3x6jF FQcUF64cnjmBWy3X3er7hObL4JGoIYPnXuRLl8SYeU3IKuGeFm90kSdsmkujz+e5kPtx sBmFi8HzQYWdNkS6RxWNl5/BBpI9jJCBdSL/mr/LcLAc0GxFlB1De8oKUHdLkMPJ0lr4 Z1LA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=gzlgSDH1; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k15-v6si5395607pff.91.2018.06.18.14.35.25; Mon, 18 Jun 2018 14:35:39 -0700 (PDT) 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=pass header.i=@kernel.org header.s=default header.b=gzlgSDH1; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755419AbeFRVde (ORCPT + 99 others); Mon, 18 Jun 2018 17:33:34 -0400 Received: from mail.kernel.org ([198.145.29.99]:38718 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755386AbeFRVdd (ORCPT ); Mon, 18 Jun 2018 17:33:33 -0400 Received: from mail-wr0-f170.google.com (mail-wr0-f170.google.com [209.85.128.170]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 5B68120852 for ; Mon, 18 Jun 2018 21:33:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1529357612; bh=V85O7nWFSZGjaL46G6qYHcLRh0WWKpLmV16XW3Ow1eg=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=gzlgSDH197Hy2Lja5bJ8Rs21VWywpAsyrppy+LDuJLk6Cx9I0YW8SckGYcWbSccVg 6tZQSe5dKNdlJejMfMACmTEdbqcLBIDr6aOAWbBpoB5YeN3eH7GJ/p1/g6D5ibnhTn 0su/6aBBGLnZBE3Z4/Cd02f3IL6ulgv/JciQSjKs= Received: by mail-wr0-f170.google.com with SMTP id d8-v6so18344695wro.4 for ; Mon, 18 Jun 2018 14:33:32 -0700 (PDT) X-Gm-Message-State: APt69E1hqd0O5tpa7GFcdl1LE9shhOx60aoR05DLu1/Qu2x7OSUCFdOo wsTGWDN1RH/MAq2u6O4I/JecYwLgpoHQ/0lfafaxRg== X-Received: by 2002:adf:85ec:: with SMTP id 41-v6mr11727642wru.120.1529357610781; Mon, 18 Jun 2018 14:33:30 -0700 (PDT) MIME-Version: 1.0 References: <20180608171216.26521-1-jarkko.sakkinen@linux.intel.com> <20180608171216.26521-10-jarkko.sakkinen@linux.intel.com> <78982a32-c589-48e2-9a83-fd36903b5588@fortanix.com> In-Reply-To: <78982a32-c589-48e2-9a83-fd36903b5588@fortanix.com> From: Andy Lutomirski Date: Mon, 18 Jun 2018 14:33:18 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [intel-sgx-kernel-dev] [PATCH v11 09/13] x86, sgx: basic routines for enclave page cache To: Jethro Beekman Cc: Jarkko Sakkinen , X86 ML , Platform Driver , npmccallum@redhat.com, LKML , Ingo Molnar , intel-sgx-kernel-dev@lists.01.org, "H. Peter Anvin" , Thomas Gleixner Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jun 18, 2018 at 8:11 AM Jethro Beekman wrote: > > On 2018-06-08 10:09, Jarkko Sakkinen wrote: > > +/* > > + * Writing the LE hash MSRs is extraordinarily expensive, e.g. > > + * 3-4x slower than normal MSRs, so we use a per-cpu cache to > > + * track the last known value of the MSRs to avoid unnecessarily > > + * writing the MSRs with the current value. Because most Linux > > + * kernels will use an LE that is signed with a non-Intel key, > > I don't think you can predict what most Linux kernels will be doing. I > think not initializing the cache to the CPU's initial value is fine, but > this particular argument shouldn't appear in the rationale. No, it's quite predictable. Upstream Linux will not permit the Intel-signed LE to be used unless Intel makes some major changes to the way the launch process works. > > > + * i.e. the first EINIT will need to write the MSRs regardless > > + * of the cache, the cache is intentionally left uninitialized > > + * during boot as initializing the cache would be pure overhead > > + * for the majority of systems. But the comment does need changes. How about saying that the cache either contains all zeros or matches the MSRs? All zeros is used when, for whatever reason, we choose not to care what the current MSR values are. Leaving it genuinely uninitialized would be incorrect. (And, of course, we're assuming that no one ever needs the MSRs zeroed.) When KVM host support goes in, even this won't be good enough if we want to allow passthrough access to the MSRs because we will no longer be able to guarantee that all zeros is invalid. Instead we'd need an actual flag saying that the cache is invalid. --Andy