Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752688AbdLDQAx (ORCPT ); Mon, 4 Dec 2017 11:00:53 -0500 Received: from mail-co1nam03on0047.outbound.protection.outlook.com ([104.47.40.47]:25568 "EHLO NAM03-CO1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751980AbdLDQAe (ORCPT ); Mon, 4 Dec 2017 11:00:34 -0500 Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Thomas.Lendacky@amd.com; Subject: Re: [PATCH] x86/mm: Rewrite sme_populate_pgd() in a more sensible way To: "Kirill A. Shutemov" Cc: "Kirill A. Shutemov" , Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , x86@kernel.org, Borislav Petkov , Brijesh Singh , linux-mm@kvack.org, linux-kernel@vger.kernel.org References: <20171204112323.47019-1-kirill.shutemov@linux.intel.com> <20171204145755.6xu2w6a6og56rq5v@node.shutemov.name> From: Tom Lendacky Message-ID: Date: Mon, 4 Dec 2017 10:00:26 -0600 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.5.0 MIME-Version: 1.0 In-Reply-To: <20171204145755.6xu2w6a6og56rq5v@node.shutemov.name> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [165.204.78.1] X-ClientProxiedBy: MWHPR22CA0068.namprd22.prod.outlook.com (10.171.142.30) To DM5PR12MB1145.namprd12.prod.outlook.com (10.168.236.140) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 18d803b9-b757-420a-81d7-08d53b302659 X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(5600026)(4604075)(4534020)(4602075)(4627115)(201703031133081)(201702281549075)(48565401081)(2017052603286);SRVR:DM5PR12MB1145; X-Microsoft-Exchange-Diagnostics: 1;DM5PR12MB1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ZB086VxACPnTsL4WJSLFe8gcVm7SiUpd0ydlqpmc+JmJyzgPgTgScXjtsQ65CwElkCSqibLcqvp2fZQWRs37emksLJQdOp1dJVlYyLMyMQ36KPYX0bk/VT3XUKlhssZpKpo3UcSllCkVL0ryqAAy3QEzAySOWr/MwGPje/0v/C3gGP+L4MKbYkBnaM+96jx5dNJmh4begj3v9aSexqCPWEBaH6UbE76RIYl5CUCXlACmQiZIn5cuUkE6tLwiq7PVxriVV2oFv3euR5me9qpWpcYrz6ZvZedhWQsSOMikKWT9und60w6B+XNU2oU9Oa3k3p/4SDPJV+pwSt+SXwS5MyAe2kr/0FjprR62CRUxG;4:ma/nV8lwYfUQDlsUzalOF7RRT9vQ85Icb6OfzWc2g+ZkBb/mg78AQ5x29ls2VFaDsFXs/Y9mP6roHEEFRowd6hzyEwsxreBA14qjUh7v45pmY5U9z3W2E1Ns1fpv22n0V1J5i9PrAXvjrU34ixibP4mFY/sgVjKoaoOdoK6ab6TCzlkHqiKa5yRWwStarOrqhQld+u2crvHLBxZW2xCBvAeoaMpM623ZgxmtYnl/Ah340SW/rUlI4MJXBCKAyba0RlKymIGcPfT43/EFZGfR9w== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(6040450)(2401047)(5005006)(8121501046)(3002001)(93006095)(93001095)(10201501046)(3231022)(6055026)(6041248)(20161123564025)(20161123560025)(20161123562025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123558100)(20161123555025)(6072148)(201708071742011);SRVR:DM5PR12MB1145;BCL:0;PCL:0;RULEID:(100000803101)(100110400095);SRVR:DM5PR12MB1145; X-Forefront-PRVS: 051158ECBB X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(6009001)(6049001)(366004)(39860400002)(346002)(376002)(189002)(24454002)(199003)(64126003)(53936002)(67846002)(83506002)(2906002)(6246003)(97736004)(6666003)(2950100002)(229853002)(2486003)(58126008)(47776003)(316002)(52146003)(65826007)(16526018)(90366009)(4326008)(5660300001)(68736007)(77096006)(52116002)(6486002)(6916009)(86362001)(7736002)(305945005)(16576012)(76176011)(31696002)(54906003)(23676004)(3260700006)(31686004)(25786009)(230700001)(101416001)(8676002)(478600001)(189998001)(54356011)(36756003)(105586002)(81156014)(81166006)(33646002)(53546010)(65956001)(8936002)(65806001)(66066001)(106356001)(3846002)(6116002)(50466002)(72206003);DIR:OUT;SFP:1101;SCL:1;SRVR:DM5PR12MB1145;H:[10.236.65.116];FPR:;SPF:None;PTR:InfoNoRecords;MX:1;A:1;LANG:en; X-Microsoft-Exchange-Diagnostics: =?utf-8?B?MTtETTVQUjEyTUIxMTQ1OzIzOmxDbTByejJnNGdjMUdqa1RKNG9xMlNIS01N?= =?utf-8?B?SFRVZHZCR1c1eUFLT0E1RjFPWE5pYWhYenNFcTJFbnNFNFdRNVp5MXRSRnVW?= =?utf-8?B?Rmcra1JQMTFCdUtFYVNXMDRqWE5hSlU1SUwrZFh2aHhPbGkvbXhzbExuT2dt?= =?utf-8?B?Myt0d1JqT0N2WjBhZUxnSHJMSjFIdVdBY3R4eS9QYndncEhkb0FYcC9QcENO?= =?utf-8?B?aUF2eUUyaWw0OGVVNmlic2w4OFg0cEh6ditDekk2SCswaTlkYTl3U0VaOUt2?= =?utf-8?B?NFNDZE40VitBQk1KYzFNbXpTNTh1eHRUZ1ZsUUM1NWRtb21mUEc5bTZ3d0xv?= =?utf-8?B?Znhlb29TVjlIZnhwSmoyblZHNDQvZXlrNzR4bUJON2RDK0t4SnlDNE1mRFNR?= =?utf-8?B?L3c5aGptQ2ZtVDI2S09oRXYrZkUzZ003WWdmNUN2R1pkQk5MS2FmU25RU0RD?= =?utf-8?B?bnZJcE1RMU9HdVhaTy8wdHU4cUsxUHhJQ0ppL1hWUUJpNEZzWEZ6STdQdyt4?= =?utf-8?B?MDJrTVUzaWxnZXRacnlQZkpGTTlHc3J1NGRNbXB1cmVLN2NpL3VoL0t0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v21mRU29vlHwzLhpfzsH5zd53MAmUvt3faM=;5:YIzhdZwELSG9bvSOEUemBbXCQkRriLUUQk+pJ4+4HUdC9YgpUqNq4LgeOAqTZBVSTWa+0zWmnBlDIUxpdLe5Mze0qUvKfU02+JLAmzSZR6EAYBD8LRVc+kSquN5zM0+SnV/0SpBAVRXdZ/zfg3IZSQ/vUNcjUTTAHVcuNUqtyo8=;24:W1p0CBsfcdllIVJioRmy6ady8vaZpwjT4KxQEGqrQWKdSaCGM33Ud7yGCVdRK3XHZsrhVzixYbMT41mm1xNjCcOypdB5V3rRqkgh34BVvmE=;7:NysLuYpNLQ0ffbpmEg81Z6DJiAuJ4WJhTAn1m1zM1bc/XYzSWHkw3T0L7dz5HIzWbZyK8LcTLxXe8UU/gPyoCg5nWEb9EtT9BvJL5oFzDHT034EdzdIEgd08UJcJzZDWMzKbBQdIbipefglGuvDaapvXGb0lxYeagkcenSo/t7L4QOCgbxlKTdk++5jdomFXYnx5neR7+PJeW1CZYKvuROejr5fwuFjDgJcpp6GqF9Onl+iTpGInu8S4n0RCY8Ea SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;DM5PR12MB1145;20:dcX9ffCuM/m7ezx/cdJsduqVkoTUUyChjzAYZvVa7NX3F3y6KqbNakCzMFGLAVf0akyvc7Rw29YbinFy7jN6ckFnGJXHGBIkxQtqiHMTCNHItxPtU2CdK3In/4KjcJYEj/OpvuBS/ndCeU1Bo9IOGgqbvmEwXVTdFU/TrRgcnVt/DtNVeZ7nStJnYJPimJPemkpqO6mvAeXVpflxr/8BOZ73jYQINsQpTNxYF61kZAkPouLiLLybQPnVAfRWtw5R X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Dec 2017 16:00:31.5193 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 18d803b9-b757-420a-81d7-08d53b302659 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR12MB1145 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1723 Lines: 44 On 12/4/2017 8:57 AM, Kirill A. Shutemov wrote: > On Mon, Dec 04, 2017 at 08:19:11AM -0600, Tom Lendacky wrote: >> On 12/4/2017 5:23 AM, Kirill A. Shutemov wrote: >>> sme_populate_pgd() open-codes a lot of things that are not needed to be >>> open-coded. >>> >>> Let's rewrite it in a more stream-lined way. >>> >>> This would also buy us boot-time switching between support between >>> paging modes, when rest of the pieces will be upstream. >> >> Hi Kirill, >> >> Unfortunately, some of these can't be changed. The use of p4d_offset(), >> pud_offset(), etc., use non-identity mapped virtual addresses which cause >> failures at this point of the boot process. > > Wat? Virtual address is virtual address. p?d_offset() doesn't care about > what mapping you're using. Yes it does. For example, pmd_offset() issues a pud_page_addr() call, which does a __va() returning a non-identity mapped address (0xffff88...). Only identity mapped virtual addresses have been setup at this point, so the use of that virtual address panics the kernel. Thanks, Tom > >> Also, calls such as __p4d(), __pud(), etc., are part of the paravirt >> support and can't be used yet, either. > > Yeah, I missed this. native_make_p?d() has to be used instead. > >> I can take a closer look at some of the others (p*d_none() and >> p*d_large()) which make use of the native_ macros, but my worry would be >> that these get changed in the future to the non-native calls and then >> boot failures occur. > > If you want to avoid paravirt altogher for whole compilation unit, one > more option would be to put #undef CONFIG_PARAVIRT before all includes. > That's hack, but it works. We already use this in arch/x86/boot/compressed > code. >