Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp2837703imm; Fri, 20 Jul 2018 05:56:41 -0700 (PDT) X-Google-Smtp-Source: AAOMgpecUC6cxcUEp5xWP0JgsVGr7X1WyKVgtwJvBntgu7Xfn1j/fCgO1uHSY3zTRxEV/WRoAcEK X-Received: by 2002:a17:902:7e43:: with SMTP id a3-v6mr1995809pln.151.1532091401424; Fri, 20 Jul 2018 05:56:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532091401; cv=none; d=google.com; s=arc-20160816; b=CgcA8QbMmVIz6qORSJsFK7mfp4iKGcnAltWSGdNbVpQMEaU/ylVkPUHzGIkpDjwiX7 lsB/ROk45RjwW5MEgi3+d9UiqbsXrrq3DqLuSFWD08eHF2zMKVZQ/QOzpRgwWAGWB/+Z FjPJQjcCBrNGfcyBLKyISWlDaJnw6p6s01eW9brR8ZULwN943gRuqIO6cbhWXyahVpVS UJgO/K7rbTDUbRrzWMP+9HuoJfIcuyf3a1uRtL+AvPKF1lM7W0U2hC6RR+xTqEuAik95 1XxGfGZD/HFzmgbYRzw7QPSirJUMGeW4CW0Ecp1Eocz/pe5xfeWG7ztfoflTu50lD4zC MgXQ== 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:arc-authentication-results; bh=NQXg/mOAWgzBI79R1/R01wFsgaLIKE5WEYU0MTVhbq8=; b=k57lTfWOPmffGpDd7hMTHCF199b63So23sR5ucnNdC3wBXR6jSykH4RaXoW1A59+kh LiZKdksnED5ayMo5JrsnyySRGXcxURvKz1ije1vsCBZO3R0IRK973nRwJXK1Dvof8lQz z7wXWm+RrwqGZlD6xo5RXNN7XyfRuCvkRfPPc2lSrgFYcF+qXvAZLGOtsbTEfceQz6DM 9kjnaZLRkCA+awmgENXnFIoi4YzM3NP5uQcYj3Smh00AQzd0QNrhJyi38FcMsQpdIndl ibWrNKdMFRrmZ2z/d7SwyQ2etJqbBeN1enA3Q8h8y/6Qaud9rWeVM/mV/oAXuPeAUAat jGPg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@shutemov-name.20150623.gappssmtp.com header.s=20150623 header.b=ybPP8S6e; 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 v9-v6si1817731pfg.123.2018.07.20.05.56.26; Fri, 20 Jul 2018 05:56:41 -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=@shutemov-name.20150623.gappssmtp.com header.s=20150623 header.b=ybPP8S6e; 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 S1731853AbeGTNoD (ORCPT + 99 others); Fri, 20 Jul 2018 09:44:03 -0400 Received: from mail-pg1-f194.google.com ([209.85.215.194]:38067 "EHLO mail-pg1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387951AbeGTNWW (ORCPT ); Fri, 20 Jul 2018 09:22:22 -0400 Received: by mail-pg1-f194.google.com with SMTP id k3-v6so6793305pgq.5 for ; Fri, 20 Jul 2018 05:34:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=shutemov-name.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=NQXg/mOAWgzBI79R1/R01wFsgaLIKE5WEYU0MTVhbq8=; b=ybPP8S6eAXd1bjivxkWDKAPF2MsESCokwyr1w6m2HPLxWjMHVF1H9KTjVuJDU+MGih xlf79/4fABrRYHiyz2WchTj4U5dnqttk9oSfH8LUW7PYSFkd6u48hHSRzkAoeqKZKuwE /E/2YSQSQ6qDFCI09LHLSsGJqW7Y2FrtykGEHt4GvVAQRzle+PKblWr4vtNS3w9G7/0/ UfBeTh95LeBx+CFN32bn2kmu93VamXfIMcORM/X/PJZySAU8gbOXROVTYj9CK34rlEub k1idzGACdQMn199ivGhWeIqA3SyPi4eh1UFhGOY3fe44fDr/GGJZvE8b4UFfHluPmtnr LqJw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=NQXg/mOAWgzBI79R1/R01wFsgaLIKE5WEYU0MTVhbq8=; b=lEF/kdxVJrOAILuEfwzW02kwyFxMyIRKSLghhfprX6Hg9U/kswOgugEXHTWlvcyx90 zNiNWVxbkcQatUHiHWwHNAbvqUjQwpMRS1uYtUlz9Fk8FpgXLpg0hafAd9mr2sVDx6mU LvRmTjiBuuBFsV0uCHi/GKU0nnG2NuycqCT/3CZQTV0IKf7tEa07xmtFLrOXM8i420AO C0eRTL88D8pCNbg5ZRnEiTXdEqW/P2fa8JQNyJwYBbQGBmU3YunCe0eJ6lSJjIWM0UF8 MPv8p1t/lBw/r3eyJpl37j+gdByRduo4mkeqa9LNx4E/mDU2vgkIa6nnGD47EheCRGVL HpMg== X-Gm-Message-State: AOUpUlGuNiY8N7u7bDOri0AG85hCUf0J5867PzfrtJYEQSffrFIQxJn1 RQVyBrxLd4fD45qSGNbMCUStXw== X-Received: by 2002:a63:4c56:: with SMTP id m22-v6mr1878239pgl.299.1532090060167; Fri, 20 Jul 2018 05:34:20 -0700 (PDT) Received: from kshutemo-mobl1.localdomain (fmdmzpr03-ext.fm.intel.com. [192.55.54.38]) by smtp.gmail.com with ESMTPSA id u1-v6sm3838600pgk.25.2018.07.20.05.34.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 20 Jul 2018 05:34:19 -0700 (PDT) Received: by kshutemo-mobl1.localdomain (Postfix, from userid 1000) id 1C1E6300254; Fri, 20 Jul 2018 15:34:16 +0300 (+03) Date: Fri, 20 Jul 2018 15:34:16 +0300 From: "Kirill A. Shutemov" To: Thomas Gleixner Cc: Dave Hansen , "Kirill A. Shutemov" , Ingo Molnar , x86@kernel.org, "H. Peter Anvin" , Tom Lendacky , Kai Huang , Jacob Pan , linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: Re: [PATCHv5 08/19] x86/mm: Introduce variables to store number, shift and mask of KeyIDs Message-ID: <20180720123415.57m2fqbdjtvnietu@kshutemo-mobl1> References: <20180717112029.42378-1-kirill.shutemov@linux.intel.com> <20180717112029.42378-9-kirill.shutemov@linux.intel.com> <1edc05b0-8371-807e-7cfa-6e8f61ee9b70@intel.com> <20180719102130.b4f6b6v5wg3modtc@kshutemo-mobl1> <20180719131245.sxnqsgzvkqriy3o2@kshutemo-mobl1> <20180719132312.75lduymla2uretax@kshutemo-mobl1> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20180622 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jul 19, 2018 at 03:40:41PM +0200, Thomas Gleixner wrote: > On Thu, 19 Jul 2018, Kirill A. Shutemov wrote: > > On Thu, Jul 19, 2018 at 03:18:03PM +0200, Thomas Gleixner wrote: > > > On Thu, 19 Jul 2018, Kirill A. Shutemov wrote: > > > > On Thu, Jul 19, 2018 at 02:37:35PM +0200, Thomas Gleixner wrote: > > > > > On Thu, 19 Jul 2018, Kirill A. Shutemov wrote: > > > > > > On Wed, Jul 18, 2018 at 04:19:10PM -0700, Dave Hansen wrote: > > > > > > > > } else { > > > > > > > > /* > > > > > > > > * Reset __PHYSICAL_MASK. > > > > > > > > @@ -591,6 +592,9 @@ static void detect_tme(struct cpuinfo_x86 *c) > > > > > > > > * between CPUs. > > > > > > > > */ > > > > > > > > physical_mask = (1ULL << __PHYSICAL_MASK_SHIFT) - 1; > > > > > > > > + mktme_keyid_mask = 0; > > > > > > > > + mktme_keyid_shift = 0; > > > > > > > > + mktme_nr_keyids = 0; > > > > > > > > } > > > > > > > > > > > > > > Should be unnecessary. These are zeroed by the compiler. > > > > > > > > > > > > No. detect_tme() called for each CPU in the system. > > > > > > > > > > And then the variables are cleared out while other CPUs can access them? > > > > > How is that supposed to work? > > > > > > > > This code path only matter in patalogical case: when MKTME configuation is > > > > inconsitent between CPUs. Basically if BIOS screwed things up we disable > > > > MKTME. > > > > > > I still don't see how that's supposed to work. > > > > > > When the inconsistent CPU is brought up _AFTER_ MKTME is enabled, then how > > > does clearing the variables help? It does not magically make all the other > > > stuff go away. > > > > We don't actually enable MKTME in kernel. BIOS does. Kernel makes choose > > to use it or not. Current design targeted to be used by userspace. > > So until init we don't have any other stuff to go away. We can just > > pretend that MKTME was never there. > > Hotplug is not guaranteed to happen _BEFORE_ init. Think about physical > hotplug. Ouch. I didn't think about this. :/ In this case I don't see how to handle the situation properly. Is it okay to WARN() && pray()? -- Kirill A. Shutemov