Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp8013554rwb; Tue, 6 Dec 2022 12:49:22 -0800 (PST) X-Google-Smtp-Source: AA0mqf43qrU4tX0Dgoctldlc+ze+uYOnA05HWrH7GxUQ6R8njPs0uA3G5dJh/Zrcuk/l1Y/MEDDm X-Received: by 2002:a62:2f42:0:b0:577:271e:bf2e with SMTP id v63-20020a622f42000000b00577271ebf2emr7334234pfv.82.1670359762253; Tue, 06 Dec 2022 12:49:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670359762; cv=none; d=google.com; s=arc-20160816; b=02hlPaEEsnqV6A+trygDB1iAVXxlhKznZP0qzuYMfDj7NYDWdho6VMujh7/BJmcMlr vE+LU1jrjuwy6EzpKPFU5CyzcG8mhr036NjE7SmoS1LoG1bnQwLDGI3UKcI8f0RZ8cQW 5F3mVRA2MrmbIT7cFhlnwplil3HSEennOetniquo6rw8nqhyLHZxDNRWn7833nGEEHMq elXWKxCD/MgSTYej7X+1/RwHCFhJrhoTi26fvg01F0Y7IxoSPT4Ac43ckF0wgsFZcWQY CENUIwT6tFmctr+7y9QoXoKTnUD0lkToB4hVlIXsI5FdgbBn17jz4pxvY+/V1TcymL4e aegg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:to:content-language:subject:user-agent:mime-version:date :message-id:dkim-signature; bh=wKk0Tw009H3V/dYmjts7Ll3tOdOgvymDJFHGuGXLP+Q=; b=0OfWFdclCqk34ueYZyA2CyXGNucDc+UYskBfC4wK0PvyVqytnBkIeE7qzGX1FaCa1w YsDD0Wh5Q3GAwgCqhi/xbcyAaMphbHvaYbqH4a+yzUqOF4uxLw47P59VljC+qCSglEnv +o02+T35MKPGKMwb778+1kS4lgHpdcHNicwTVSlbcHqxN6HPgMAr27PIz2Viep/DT/9u kYgr7yFJfEvbCIofZPkYnp1KXdcnuP1YfJaauJP9EF0tGnqaSHOnCHNbKD4zehvM4qBc 3oovYsHJRd5GDBVT3FE6PlaiHTbU2oq3ibP8wJx8fwMVp7NiaFW5Q5jkGKM80vc3uca9 U+Vg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=SLFPOyb4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id jc18-20020a17090325d200b00174eef66680si17706457plb.120.2022.12.06.12.49.11; Tue, 06 Dec 2022 12:49:22 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=SLFPOyb4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229638AbiLFUa3 (ORCPT + 77 others); Tue, 6 Dec 2022 15:30:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59732 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229445AbiLFUaZ (ORCPT ); Tue, 6 Dec 2022 15:30:25 -0500 Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7672340903; Tue, 6 Dec 2022 12:30:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1670358624; x=1701894624; h=message-id:date:mime-version:subject:to:references:from: in-reply-to:content-transfer-encoding; bh=cKNUhoCiYNYxcj4olMwEpjiNpmt1LAcQUcHFx6HzQpQ=; b=SLFPOyb4xSgXi6DJPhwUK+7I7MdRjHEZV7rmBimV5AL2oCNvLiVxGpv2 GZa8SPq0yJNIgihvcg+HyoTNV8U4+18NiiBLE2Yt/cqDT5GAlAIXwEJxt 8UqfNAF1eVMmbbzEi4LR/F41VqunmPo1Xy477DQyBnSaz6nmk/j6wqYvm +AiAqQggJMVIJYhMEhEwg2cJmb+oTpS9Y5Wpk5heV8QLZSsdGU/BpM1yb hGQDb0fL3lUhq89bPBH2KVQLZlU3JA9XGfPtTWH7zelaHjiT5BI+c9uhS 4WnBt52vFtq57HYQ+yV2jsvJKX+0eDAflpYIjFf6cJ+OLCuU0trqyzcKp A==; X-IronPort-AV: E=McAfee;i="6500,9779,10553"; a="297080636" X-IronPort-AV: E=Sophos;i="5.96,223,1665471600"; d="scan'208";a="297080636" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Dec 2022 12:30:23 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10553"; a="788621078" X-IronPort-AV: E=Sophos;i="5.96,223,1665471600"; d="scan'208";a="788621078" Received: from smaslov-mobl3.amr.corp.intel.com (HELO [10.251.23.186]) ([10.251.23.186]) by fmsmga001-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Dec 2022 12:30:21 -0800 Message-ID: Date: Tue, 6 Dec 2022 12:30:21 -0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Firefox/102.0 Thunderbird/102.4.2 Subject: Re: [Patch v4 05/13] init: Call mem_encrypt_init() after Hyper-V hypercall init is done Content-Language: en-US To: "Michael Kelley (LINUX)" , "hpa@zytor.com" , KY Srinivasan , Haiyang Zhang , "wei.liu@kernel.org" , Dexuan Cui , "luto@kernel.org" , "peterz@infradead.org" , "davem@davemloft.net" , "edumazet@google.com" , "kuba@kernel.org" , "pabeni@redhat.com" , "lpieralisi@kernel.org" , "robh@kernel.org" , "kw@linux.com" , "bhelgaas@google.com" , "arnd@arndb.de" , "hch@infradead.org" , "m.szyprowski@samsung.com" , "robin.murphy@arm.com" , "thomas.lendacky@amd.com" , "brijesh.singh@amd.com" , "tglx@linutronix.de" , "mingo@redhat.com" , "bp@alien8.de" , "dave.hansen@linux.intel.com" , Tianyu Lan , "kirill.shutemov@linux.intel.com" , "ak@linux.intel.com" , "isaku.yamahata@intel.com" , "Williams, Dan J" , "jane.chu@oracle.com" , "seanjc@google.com" , "tony.luck@intel.com" , "x86@kernel.org" , "linux-kernel@vger.kernel.org" , "linux-hyperv@vger.kernel.org" , "netdev@vger.kernel.org" , "linux-pci@vger.kernel.org" , "linux-arch@vger.kernel.org" , "iommu@lists.linux.dev" References: <1669951831-4180-1-git-send-email-mikelley@microsoft.com> <1669951831-4180-6-git-send-email-mikelley@microsoft.com> <51fb66d6-f2e0-f11c-68a3-525723d56dd4@linux.intel.com> From: Sathyanarayanan Kuppuswamy In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 12/6/22 12:13 PM, Michael Kelley (LINUX) wrote: > From: Sathyanarayanan Kuppuswamy >> >> >> >> On 12/1/22 7:30 PM, Michael Kelley wrote: >>> Full Hyper-V initialization, including support for hypercalls, is done >>> as an apic_post_init callback via late_time_init(). mem_encrypt_init() >>> needs to make hypercalls when it marks swiotlb memory as decrypted. >>> But mem_encrypt_init() is currently called a few lines before >>> late_time_init(), so the hypercalls don't work. >> >> Did you consider moving hyper-v hypercall initialization before >> mem_encrypt_init(). Is there any dependency issue? > > Hyper-V initialization has historically been done using the callbacks > that exist in the x86 initialization paths, rather than adding explicit > Hyper-V init calls. As noted above, the full Hyper-V init is done on > the apic_post_init callback via late_time_init(). Conceivably we could > add an explicit call to do the Hyper-V init, but I think there's still a > problem in putting that Hyper-V init prior to the current location of > mem_encrypt_init(). I'd have to go check the history, but I think the > Hyper-V init needs to happen after the APIC is initialized. Ok. If there is a dependency or complexity issue, I recommend adding that detail in the commit log. > > It seems like moving mem_encrypt_init() slightly later is the cleaner > long-term solution. Are you aware of a likely problem arising in the > future with moving mem_encrypt_init()? I did not investigate in depth, but there appears to be no problem with moving mem_encrypt_init(). But my point is, if it is possible to fix this easily by changing Hyper-v specific initialization, we should consider it first before considering moving the common mem_encrypt_init() function. > > Michael > >> >>> >>> Fix this by moving mem_encrypt_init() after late_time_init() and >>> related clock initializations. The intervening initializations don't >>> do any I/O that requires the swiotlb, so moving mem_encrypt_init() >>> slightly later has no impact. >>> -- Sathyanarayanan Kuppuswamy Linux Kernel Developer