Received: by 2002:a05:7412:98c1:b0:fa:551:50a7 with SMTP id kc1csp1891401rdb; Mon, 8 Jan 2024 13:58:44 -0800 (PST) X-Google-Smtp-Source: AGHT+IHwDzxar2l7iYBnsWXMGnnGKRVWPWSj8sfP6Z/SNU1t2jMAw/8PkBREMoH2JUkrbmh8ekrU X-Received: by 2002:a05:6a00:e13:b0:6d9:c201:676b with SMTP id bq19-20020a056a000e1300b006d9c201676bmr5027961pfb.24.1704751124446; Mon, 08 Jan 2024 13:58:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704751124; cv=none; d=google.com; s=arc-20160816; b=GXQfdK0/nnfz9x9hOg5DpZ/dXPSIEgq5A/PjXFg37Cd5RluVFmkTcZ58VJZeq0TQHa 4fBTcKQHRFEFVwzaeQ44UmyH8KHmBfYo8hKEB0gO3dRZsOAojFPK8ZyzV21Jo/4T941B P+J62soJcLi8xkKSmSi+zrZA5oNmIk4XY9RJ8th0VU7stg4oD4RbqzVN0Ve0Arl8x274 nJ/fmWW1Sc6r48jLHjk5kls+Z+FZI+FVRv4Ep5fqDAbK+GCTISh+dwR34yX7750YFH6m IlD+UQkLfEo3TWhzB4GnT1jbNqH6gZQgI9YslxqsP9+d0T8onBHzAmzHSGiKaIiYgUfm 4P4Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=MgXTF/L8/T8lZoR7JQyyrWrydTOQ7BZU5rOr2w36cWA=; fh=6NvX7TVzAR/V+8LmIJqd0IErjPhe0yk6sYKNGKb4hs0=; b=00IfQH/yf83LIABo+Oivf01fq4R2mHj88yQt8+v2dfvhHJcanJqoap7WcJ9PwnC0Q+ W4aeq0SjeAp+myP9akjAnRfekttcMEhYzV4DpHF3t07EKgFDUGbGIfojdMpuZoY/NRjV 1T4qHJlsxh3MS/+copguMy3IAqWXK8NKhABLJlydL45xmyxbAP/Sq2+CUl8nZC0KS/V6 Tmnj/YXnlQz6AX4sQGUunZyhoYp67iCDcQyyBc1zv9KTQq3FqxIY8l083HuiJkzbfDRq oDr9PRY1pbIypUDsQzXfaLlL65E5fO+p7GdJdxhqZQI53MF6TQy11OT9QhG7ikX0EHDe JvSA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=iBlo94uZ; spf=pass (google.com: domain of linux-kernel+bounces-20138-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-20138-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id 199-20020a6302d0000000b005ce01eee2afsi404388pgc.836.2024.01.08.13.58.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Jan 2024 13:58:44 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-20138-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=iBlo94uZ; spf=pass (google.com: domain of linux-kernel+bounces-20138-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-20138-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 593CDB22CC3 for ; Mon, 8 Jan 2024 21:58:41 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A53C456464; Mon, 8 Jan 2024 21:58:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="iBlo94uZ" Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6F9B05645E for ; Mon, 8 Jan 2024 21:58:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1704751113; x=1736287113; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=QWtHOj9jcmef+zZ+8hvlkxNwgvkmKP+JDW0HCkknOWc=; b=iBlo94uZDp5l7Qwhlv3AoN1/UQhB3FxvuHLup9ZBmUhqdXFwH8mcObfi 57kULn/BskHNABHX/ldPej4OfGnO/jeZQDUm5sRmJCHflg3pY3pYZ/7jQ SwYFX0V7BY+NBwGU4NHUXJXpwz9KRWRvbHNsi1cUuwuP3EGHnyUbxuzpW vlWuCMrE8cTKZYDTTz0j9S4/6tpBbwltlRZLtBn89TZV4pgQXO5Wmwvhu gSBSXBPdN/3EoMmMrzghWxLyBORs7+UBUydZ83N7/dt86BkLbP4iqOEU0 Nj+BnwT7WX+Jp7/b13gnk98kc/NjQvARZC0vexwh5lcHBIb4Uz7AcTYqX Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10947"; a="19518179" X-IronPort-AV: E=Sophos;i="6.04,180,1695711600"; d="scan'208";a="19518179" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmvoesa101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Jan 2024 13:58:32 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10947"; a="757750785" X-IronPort-AV: E=Sophos;i="6.04,181,1695711600"; d="scan'208";a="757750785" Received: from ddraghic-mobl.ger.corp.intel.com (HELO box.shutemov.name) ([10.251.212.53]) by orsmga006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Jan 2024 13:58:29 -0800 Received: by box.shutemov.name (Postfix, from userid 1000) id AD78B10944C; Tue, 9 Jan 2024 00:58:26 +0300 (+03) Date: Tue, 9 Jan 2024 00:58:26 +0300 From: "Kirill A. Shutemov" To: Sean Christopherson Cc: Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , linux-kernel@vger.kernel.org, Andi Kleen Subject: Re: [PATCHv2] x86/trampoline: Bypass compat mode in trampoline_start64() if not needed Message-ID: <20240108215826.mgiasmqh6hmy2zwa@box.shutemov.name> References: <20240107122847.27740-1-kirill.shutemov@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: On Mon, Jan 08, 2024 at 08:18:55AM -0800, Sean Christopherson wrote: > On Sun, Jan 07, 2024, Kirill A. Shutemov wrote: > > @@ -220,6 +222,33 @@ SYM_CODE_START(trampoline_start64) > > lidt tr_idt(%rip) > > lgdt tr_gdt64(%rip) > > > > + /* Check if paging mode has to be changed */ > > + movq %cr4, %rax > > + xorq tr_cr4(%rip), %rax > > This is buggy, tr_cr4 is only 4 bytes. And even if tr_cr4 were 8 bytes, the reason > why nothing showed up in testing is also why only 4 bytes need to be XOR'd: the > upper 32 bits of the result are never consumed. Oh. Good catch. Will fix. tr_cr4 will need to be changed to 8 bytes soonish. FRED uses bit 32 of the register. > > + andq $X86_CR4_LA57, %rax > > Nit, this can be TEST instead of AND, e.g. I was looking to see if RAX was used > anywhere in the flow. And in theory it's possible a CPU could support uop fusing > for TEST+Jcc but not AND+Jcc, cause shaving a cycle in this code is obviously > super important ;-) > > And as above, testl, not testq. Fair enough. Will use testl. -- Kiryl Shutsemau / Kirill A. Shutemov