Received: by 2002:ac0:e350:0:0:0:0:0 with SMTP id g16csp370590imn; Wed, 3 Aug 2022 07:25:13 -0700 (PDT) X-Google-Smtp-Source: AA6agR7/VvH6FqHJd5s3whVaKoaagmE2h9YXusR1DmqLptUqo41Ajw1l9ELf3UFTGgIcbaTr1/1Z X-Received: by 2002:a17:90b:3e89:b0:1f0:4233:b20e with SMTP id rj9-20020a17090b3e8900b001f04233b20emr5289912pjb.0.1659536712826; Wed, 03 Aug 2022 07:25:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659536712; cv=none; d=google.com; s=arc-20160816; b=dXI191xa0sPuiRBYBEF4seNqq2wEy+UqBWF0bNa9K/e2IW+GrGnr5T0wfVDV5593Jn V/Y+/K6RG02+D70CU05LyKcsHG08FuSe0fAVRIL6X23SUIPHWEvbozz5R8KwSjZP+viL vHzZZfYIgfW4cKxm8DJvR1PW1Cg2DziGHI9nWIb/T2reFgrt49m3FtvIDa08S8/ZuUd1 fsLuk818JrMYRd/tLQwAgrvF98mAYt0DC3PFJlGriz+2jawha4z1lUlyaUFADjcJtL1o +jS+PlcVUrz6yop9bTISs1zSQvQW9PtlGgfH5Wy8VJitvNw49KLUKhuYbU73EPt89aHP TZRg== 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:references :cc:to:from:content-language:subject:user-agent:mime-version:date :message-id:dkim-signature; bh=WVtdDF+Fy+grSt7TGYAvHZ6Xmo7A80+3mYKj8PtNfJM=; b=K89KaZ/O/FLJG4zOxWEJxoWwrqSOXGiyVMcdpCF83vkXgH8+Laj0AcKtvt05Vm98v0 0IXpKfMDJv7iTbzsiqA9waVbQMiWXr4ReGE2SGkx/14mAUb8crE/mmMxnd0gYKfg9oWx Dt4ZPs9DhT5A0GcPI4VJcdyTZge9tq5dRWinMXfpYOjXULn4hVqjfkYt/jDDeriPhe+W d3yOyd80AcyBc8m8RWyuxmFN+a/6vB9OgmI6W2A//NqgkvMgmj+UAlt6CljKnjf+yJ9f RHKL6SOMB/mh5l6kzVUAeLJSxadcSUOFyyx1k3ZhP48QZNc2QvnhHgJvN/n+PQo4/DIQ koEw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=hx32VLxK; 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 i1-20020a17090332c100b0016edf7ced85si2961547plr.113.2022.08.03.07.24.51; Wed, 03 Aug 2022 07:25:12 -0700 (PDT) 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=hx32VLxK; 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 S236785AbiHCOCh (ORCPT + 99 others); Wed, 3 Aug 2022 10:02:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56318 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238048AbiHCOCe (ORCPT ); Wed, 3 Aug 2022 10:02:34 -0400 Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 425DE2CE1C; Wed, 3 Aug 2022 07:02:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1659535352; x=1691071352; h=message-id:date:mime-version:subject:from:to:cc: references:in-reply-to:content-transfer-encoding; bh=3kbiD6sIxSxAjVpFKmkjnzMfUr0hXQ3N3rtFHjcQbH4=; b=hx32VLxKoA7yyXx+uPpqfWeyh1L5SxpNJCDxVR1v/8QoGsH20dP+s3Mh J5uWD+xrZ4URuqYuj0ZQAf7lNeGHSRkElDAM3Uuakvwml+AL/el2o7VKQ CuAY5DxWDi4ROqj6Qv9aqr8ff50B9UJELoZeEMdSCL0HXEP4CxgOXXqdf Q4Vqqyf9cHkqDg7nt4MXwZt3JnegAxG3UEU5qd7hfAwk5GfQ+3GxaLPsC vLOyaJcpxQebQ8lTWf3JeOqVu/e2jnd0CJ6IovXjt0ucUJxNAVTgFp6eN GxbJeDuNd+El9dQtsgBKuYfmNrURhqNp1YvEx8yRbWINAN1XWyxGYzdts g==; X-IronPort-AV: E=McAfee;i="6400,9594,10428"; a="375977435" X-IronPort-AV: E=Sophos;i="5.93,214,1654585200"; d="scan'208";a="375977435" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Aug 2022 07:02:31 -0700 X-IronPort-AV: E=Sophos;i="5.93,214,1654585200"; d="scan'208";a="631159385" Received: from buichris-mobl.amr.corp.intel.com (HELO [10.209.124.150]) ([10.209.124.150]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Aug 2022 07:02:30 -0700 Message-ID: <073c5a97-272c-c5a0-19f2-c3f14f916c72@intel.com> Date: Wed, 3 Aug 2022 07:02:31 -0700 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.11.0 Subject: Re: [PATCHv7 10/14] x86/mm: Avoid load_unaligned_zeropad() stepping into unaccepted memory Content-Language: en-US From: Dave Hansen To: Borislav Petkov , "Kirill A. Shutemov" Cc: Andy Lutomirski , Sean Christopherson , Andrew Morton , Joerg Roedel , Ard Biesheuvel , Andi Kleen , Kuppuswamy Sathyanarayanan , David Rientjes , Vlastimil Babka , Tom Lendacky , Thomas Gleixner , Peter Zijlstra , Paolo Bonzini , Ingo Molnar , Varad Gautam , Dario Faggioli , Mike Rapoport , David Hildenbrand , marcelo.cerri@canonical.com, tim.gardner@canonical.com, khalid.elmously@canonical.com, philip.cox@canonical.com, x86@kernel.org, linux-mm@kvack.org, linux-coco@lists.linux.dev, linux-efi@vger.kernel.org, linux-kernel@vger.kernel.org References: <20220614120231.48165-1-kirill.shutemov@linux.intel.com> <20220614120231.48165-11-kirill.shutemov@linux.intel.com> <80cc204b-a24f-684f-ec66-1361b69cae39@intel.com> In-Reply-To: <80cc204b-a24f-684f-ec66-1361b69cae39@intel.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-5.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,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 8/2/22 16:46, Dave Hansen wrote: > To sum it all up, I'm not happy with the complexity of the page > acceptance code either but I'm not sure that it's bad tradeoff compared > to greater #VE complexity or fragility. > > Does anyone think we should go back and really reconsider this? One other thing I remembered as I re-read my write up on this. In the "new" mode, guests never get #VE's for unaccepted memory. They just exit to the host and can never be reentered. They must be killed. In the "old" mode, I _believe_ that the guest always gets a #VE for non-EPT-present memory. The #VE is basically the same no matter if the page is unaccepted or if the host goes out and makes a previously-accepted page non-present. One really nasty implication of this "old" mode is that the host can remove *accepted* pages that are used in the syscall gap. That means that the #VE handler would need to be of the paranoid variety which opens up all kinds of other fun. * "Old" - #VE's can happen in the syscall gap * "New" - #VE's happen at better-defined times. Unexpected ones are fatal. There's a third option which I proposed but doesn't yet exist. The TDX module _could_ separate the behavior of unaccepted memory #VE's and host-induced #VEs. This way, we could use load_unaligned_zeropad() with impunity and handle it in the #VE handler. At the same time, the host would not be allowed to remove accepted memory and cause problems in the syscall gap. Kinda the best of both worlds. But, I'm not sure how valuable that would be now that we have the (admittedly squirrelly) code to avoid load_unaligned_zeropad() #VE's.